Ejemplo n.º 1
0
 public function setServerFtpAccess($server, $accessMode)
 {
     $ftpUser = FtpUser::model()->findByAttributes(array('name' => $this->name));
     if (!$ftpUser) {
         $ftpUser = new FtpUser();
         $ftpUser->syncWithUser($this);
         if (!$ftpUser->save()) {
             return false;
         }
     }
     $access = FtpUserServer::model()->findByAttributes(array('user_id' => $ftpUser->id, 'server_id' => $server));
     if (!$access) {
         $access = new FtpUserServer();
         $access->user_id = $ftpUser->id;
         $access->server_id = $server;
     }
     if ($accessMode == 'rw') {
         $access->perms = 'elradfmw';
     } else {
         if ($accessMode == 'ro') {
             $access->perms = 'elr';
         } else {
             $access->perms = '';
         }
     }
     return $access->save();
 }