Esempio n. 1
0
 public function request($url, $params = array())
 {
     if (empty(\GO::config()->serverclient_server_url)) {
         \GO::config()->serverclient_server_url = \GO::config()->full_url;
     }
     $url = \GO::config()->serverclient_server_url . '?r=' . $url;
     if (empty(\GO::config()->serverclient_token)) {
         throw new \Exception("Could not connect to mailserver. Please set a strong password in /etc/groupoffice/globalconfig.inc.php.\n\nPlease remove serverclient_username and serverclient_password.\n\nPlease add:\n\n \$config['serverclient_token']='aStrongPasswordOfYourChoice';");
     }
     $params['serverclient_token'] = \GO::config()->serverclient_token;
     return parent::request($url, $params);
 }
Esempio n. 2
0
 protected function afterSubmit(&$response, &$model, &$params, $modifiedAttributes)
 {
     $stmt = \GO\Addressbook\Model\Addresslist::model()->find(\GO\Base\Db\FindParams::newInstance()->permissionLevel(\GO\Base\Model\Acl::WRITE_PERMISSION));
     while ($addresslist = $stmt->fetch()) {
         $linkModel = $addresslist->hasManyMany('contacts', $model->id);
         $mustHaveLinkModel = isset($params['addresslist_' . $addresslist->id]);
         if ($linkModel && !$mustHaveLinkModel) {
             $linkModel->delete();
         }
         if (!$linkModel && $mustHaveLinkModel) {
             $addresslist->addManyMany('contacts', $model->id);
         }
     }
     if (!empty($params['delete_photo'])) {
         $model->removePhoto();
         $model->save();
     }
     if (isset($_FILES['image']['tmp_name'][0]) && is_uploaded_file($_FILES['image']['tmp_name'][0])) {
         $destinationFile = new \GO\Base\Fs\File(\GO::config()->getTempFolder()->path() . '/' . $_FILES['image']['name'][0]);
         move_uploaded_file($_FILES['image']['tmp_name'][0], $destinationFile->path());
         $model->setPhoto($destinationFile);
         $model->save();
         $response['photo_url'] = $model->photoThumbURL;
         $response['original_photo_url'] = $model->photoURL;
     } elseif (!empty($params['download_photo_url'])) {
         $file = \GO\Base\Fs\File::tempFile();
         $c = new \GO\Base\Util\HttpClient();
         if (!$c->downloadFile($params['download_photo_url'], $file)) {
             throw new \Exception("Could not download photo from: '" . $params['download_photo_url'] . "'");
         }
         $model->setPhoto($file);
         $model->save();
         $response['photo_url'] = $model->photoThumbURL;
         $response['original_photo_url'] = $model->photoURL;
     }
     return parent::afterSubmit($response, $model, $params, $modifiedAttributes);
 }
Esempio n. 3
0
 protected function actionCheckVersion()
 {
     $rssUrl = "https://sourceforge.net/api/file/index/project-id/76359/mtime/desc/limit/20/rss";
     $httpClient = new \GO\Base\Util\HttpClient();
     $response = $httpClient->request($rssUrl);
     $sXml = simplexml_load_string($response);
     $firstItem = $sXml->channel->item[0];
     $link = (string) $firstItem->link;
     preg_match('/-([0-9]\\.[0-9]{1,2}\\.[0-9]{1,2})\\./', $link, $matches);
     $version = $matches[1];
     $ret = version_compare(GO::config()->version, $version);
     if ($ret !== -1) {
         echo "A new version ({$version}) is available at {$link}";
     } else {
         echo "Your running the latest version";
     }
 }
Esempio n. 4
0
 private static function _savePhoto(&$response, &$model, &$params)
 {
     if (!empty($params['delete_photo'])) {
         $model->removePhoto();
         $model->save();
     }
     if (isset($_FILES['image']['tmp_name'][0]) && is_uploaded_file($_FILES['image']['tmp_name'][0])) {
         $destinationFile = new \GO\Base\Fs\File(\GO::config()->getTempFolder()->path() . '/' . $_FILES['image']['name'][0]);
         move_uploaded_file($_FILES['image']['tmp_name'][0], $destinationFile->path());
         $model->setPhoto($destinationFile);
         $model->save();
         $response['photo_url'] = $model->photoThumbURL;
         $response['original_photo_url'] = $model->photoURL;
     } elseif (!empty($params['download_photo_url'])) {
         $file = \GO\Base\Fs\File::tempFile();
         $c = new \GO\Base\Util\HttpClient();
         if (!$c->downloadFile($params['download_photo_url'], $file)) {
             throw new \Exception("Could not download photo from: '" . $params['download_photo_url'] . "'");
         }
         $model->setPhoto($file);
         $model->save();
         $response['photo_url'] = $model->photoThumbURL;
         $response['original_photo_url'] = $model->photoURL;
     }
 }