Esempio n. 1
0
 function insertFile($id_file, $area, $title, $description, $file_descriptor, $file_policy)
 {
     require_once _base_ . '/lib/lib.user.php';
     require_once _base_ . '/lib/lib.user_profile.php';
     $user_data = new DoceboUser(getLogUserId());
     $user_profile_data = new UserProfileData();
     $file_name = '';
     if ($file_descriptor != '') {
         // save file
         $file_name = $this->saveFile($area, $file_descriptor);
     }
     $file_size = Get::file_size($GLOBALS['where_files_relative'] . $this->getFilePath() . $file_name);
     if (!$file_size) {
         $file_size = 0;
     }
     $total_used_quota = $file_size + $user_profile_data->getUsedQuota(getLogUserId());
     $max_quota = $user_profile_data->getQuotaLimit(getLogUserId()) * 1024 * 1024;
     if ($total_used_quota <= $max_quota) {
         if (!$id_file) {
             if ($file_name == '') {
                 return false;
             }
             $query = "\r\n\t\t\t\tINSERT INTO " . $this->getFilesTable() . " ( owner, area, title, description, file_name, file_policy, size ) VALUES \r\n\t\t\t\t(\t'" . $this->id_user . "', \r\n\t\t\t\t\t'" . $area . "', \r\n\t\t\t\t\t'" . $title . "', \r\n\t\t\t\t\t'" . $description . "', \r\n\t\t\t\t\t'" . addslashes($file_name) . "', \r\n\t\t\t\t\t'" . $file_policy . "', \r\n\t\t\t\t\t'" . $file_size . "' )";
             if (!$this->_query($query)) {
                 return false;
             }
             $result = $user_data->updateUserUsedSpace($this->id_user);
             $id_file = $this->_last_id();
             return $id_file;
         } else {
             $query = "\r\n\t\t\t\tUPDATE " . $this->getFilesTable() . " \r\n\t\t\t\tSET area = '" . $area . "', \r\n\t\t\t\t\ttitle = '" . $title . "', \r\n\t\t\t\t\tdescription = '" . $description . "', \r\n\t\t\t\t\tfile_policy = '" . $file_policy . "' ";
             if ($file_name != '' || $file_name != false) {
                 $query .= ", file_name = '" . addslashes($file_name) . "'";
             }
             $query .= " WHERE id_file = '" . $id_file . "' AND owner = '" . $this->id_user . "'";
             if (!$this->_query($query)) {
                 return false;
             }
             return $id_file;
         }
     }
     sl_open_fileoperations();
     sl_unlink($this->getFilePath() . $file_name);
     sl_close_fileoperations();
     return false;
 }
Esempio n. 2
0
 /**
  * {@inheritDoc}
  * @see IPluggableUserProfile::setParam()
  */
 public function setParam($key, $value)
 {
     $datas = $this->userProfileDatas;
     foreach ($datas as $datum) {
         /* @var $datum UserProfileData */
         if ($datum->datakey === $key) {
             $datum->payload = $value;
             return $datum->save();
         }
     }
     $data = new UserProfileData();
     $data->user_profile_id = $this->user_profile_id;
     $data->datakey = $key;
     $data->payload = $value;
     return $data->save();
 }