mcramer
2012-08-16 5712a61048ae34365a1a8977d3fa04ddaa1b80c1
Implemented FS#1938 - Add functions to manage password protected folders to remote api 

2 files modified
107 ■■■■■ changed files
interface/lib/classes/remoting.inc.php 106 ●●●●● patch | view | raw | blame | history
interface/web/sites/lib/remote.conf.php 1 ●●●● patch | view | raw | blame | history
interface/lib/classes/remoting.inc.php
@@ -1550,6 +1550,112 @@
        return $affected_rows;
    }
    
    // ----------------------------------------------------------------------------------------------------------
    //* Get record details
    public function sites_web_folder_get($session_id, $primary_id)
    {
        global $app;
        if(!$this->checkPerm($session_id, 'sites_web_folder_get')) {
            $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
        }
        $app->uses('remoting_lib');
        $app->remoting_lib->loadFormDef('../sites/form/web_folder.tform.php');
        return $app->remoting_lib->getDataRecord($primary_id);
    }
    //* Add a record
    public function sites_web_folder_add($session_id, $client_id, $params)
    {
        if(!$this->checkPerm($session_id, 'sites_web_folder_add')) {
            $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
        }
        return $this->insertQuery('../sites/form/web_folder.tform.php',$client_id,$params);
    }
    //* Update a record
    public function sites_web_folder_update($session_id, $client_id, $primary_id, $params)
    {
        if(!$this->checkPerm($session_id, 'sites_web_folder_update')) {
            $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
        }
        $affected_rows = $this->updateQuery('../sites/form/web_folder.tform.php',$client_id,$primary_id,$params);
        return $affected_rows;
    }
    //* Delete a record
    public function sites_web_folder_delete($session_id, $primary_id)
    {
        global $app;
        if(!$this->checkPerm($session_id, 'sites_web_folder_delete')) {
            $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
        }
        // Delete all users that belong to this folder. - taken from web_folder_delete.php
        $records = $app->db->queryAllRecords("SELECT web_folder_user_id FROM web_folder_user WHERE web_folder_id = '".intval($primary_id)."'");
        foreach($records as $rec) {
            $this->deleteQuery('../sites/form/web_folder_user.tform.php',$rec['web_folder_user_id']);
            //$app->db->datalogDelete('web_folder_user','web_folder_user_id',$rec['web_folder_user_id']);
        }
        unset($records);
        $affected_rows = $this->deleteQuery('../sites/form/web_folder.tform.php',$primary_id);
        return $affected_rows;
    }
    // -----------------------------------------------------------------------------------------------
    //* Get record details
    public function sites_web_folder_user_get($session_id, $primary_id)
    {
        global $app;
        if(!$this->checkPerm($session_id, 'sites_web_folder_user_get')) {
            $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
        }
        $app->uses('remoting_lib');
        $app->remoting_lib->loadFormDef('../sites/form/web_folder_user.tform.php');
        return $app->remoting_lib->getDataRecord($primary_id);
    }
    //* Add a record
    public function sites_web_folder_user_add($session_id, $client_id, $params)
    {
        if(!$this->checkPerm($session_id, 'sites_web_folder_user_add')) {
            $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
        }
        return $this->insertQuery('../sites/form/web_folder_user.tform.php',$client_id,$params);
    }
    //* Update a record
    public function sites_web_folder_user_update($session_id, $client_id, $primary_id, $params)
    {
        if(!$this->checkPerm($session_id, 'sites_web_folder_user_update')) {
            $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
        }
        $affected_rows = $this->updateQuery('../sites/form/web_folder_user.tform.php',$client_id,$primary_id,$params);
        return $affected_rows;
    }
    //* Delete a record
    public function sites_web_folder_user_delete($session_id, $primary_id)
    {
        if(!$this->checkPerm($session_id, 'sites_web_folder_user_delete')) {
            $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
        }
        $affected_rows = $this->deleteQuery('../sites/form/web_folder_user.tform.php',$primary_id);
        return $affected_rows;
    }
    // -----------------------------------------------------------------------------------------------
    
    //* Get record details
interface/web/sites/lib/remote.conf.php
@@ -1,6 +1,7 @@
<?php
$function_list['sites_cron_get,sites_cron_add,sites_cron_update,sites_cron_delete'] = 'Sites cron functions';
$function_list['sites_database_get,sites_database_add,sites_database_update,sites_database_delete, sites_database_get_all_by_user'] = 'Sites database functions';
$function_list['sites_web_folder_get,sites_web_folder_add,sites_web_folder_update,sites_web_folder_delete,sites_web_folder_user_get,sites_web_folder_user_add,sites_web_folder_user_update,sites_web_folder_user_delete'] = 'Sites Protected folder functions';
$function_list['sites_ftp_user_get,sites_ftp_user_add,sites_ftp_user_update,sites_ftp_user_delete'] = 'Sites FTP-User functions';
$function_list['sites_shell_user_get,sites_shell_user_add,sites_shell_user_update,sites_shell_user_delete'] = 'Sites Shell-User functions';
$function_list['sites_web_domain_get,sites_web_domain_add,sites_web_domain_update,sites_web_domain_delete,sites_web_domain_set_status'] = 'Sites Domain functions';