Exemplo n.º 1
0
 /**
  * The code that needs to be called when the cron is running
  *
  * @param GO\Base\Cron\CronJob $cronJob
  * @param GO\Base\Model\User $user
  */
 public function run(GO\Base\Cron\CronJob $cronJob, GO\Base\Model\User $user = null)
 {
     $filesStmt = File::model()->find(FindParams::newInstance()->ignoreAcl()->criteria(FindCriteria::newInstance()->addCondition('expire_time', time(), '<')->addCondition('expire_time', '0', '>')->addCondition('random_code', '', '!=')->addCondition('delete_when_expired', '1')));
     foreach ($filesStmt as $fileModel) {
         $fileModel->delete();
     }
 }
Exemplo n.º 2
0
 /**
  * The code that needs to be called when the cron is running
  * 
  * If $this->enableUserAndGroupSupport() returns TRUE then the run function 
  * will be called for each $user. (The $user parameter will be given)
  * 
  * If $this->enableUserAndGroupSupport() returns FALSE then the 
  * $user parameter is null and the run function will be called only once.
  * 
  * @param CronJob $cronJob
  * @param \GO\Base\Model\User $user [OPTIONAL]
  */
 public function run(CronJob $cronJob, \GO\Base\Model\User $user = null)
 {
     \GO::session()->runAsRoot();
     $usersStmt = \GO\Base\Model\User::model()->findByAttribute('mail_reminders', 1);
     while ($userModel = $usersStmt->fetch()) {
         \GO::debug("Sending mail reminders to " . $userModel->username);
         $remindersStmt = \GO\Base\Model\Reminder::model()->find(\GO\Base\Db\FindParams::newInstance()->joinModel(array('model' => 'GO\\Base\\Model\\ReminderUser', 'localTableAlias' => 't', 'localField' => 'id', 'foreignField' => 'reminder_id', 'tableAlias' => 'ru'))->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('user_id', $userModel->id, '=', 'ru')->addCondition('time', time(), '<', 'ru')->addCondition('mail_sent', '0', '=', 'ru')));
         while ($reminderModel = $remindersStmt->fetch()) {
             //					$relatedModel = $reminderModel->getRelatedModel();
             //					var_dump($relatedModel->name);
             //					$modelName = $relatedModel ? $relatedModel->localizedName : \GO::t('unknown');
             $subject = \GO::t('reminder') . ': ' . $reminderModel->name;
             $time = !empty($reminderModel->vtime) ? $reminderModel->vtime : $reminderModel->time;
             date_default_timezone_set($userModel->timezone);
             $body = \GO::t('time') . ': ' . date($userModel->completeDateFormat . ' ' . $userModel->time_format, $time) . "\n";
             $body .= \GO::t('name') . ': ' . str_replace('<br />', ',', $reminderModel->name) . "\n";
             //					date_default_timezone_set(\GO::user()->timezone);
             $message = \GO\Base\Mail\Message::newInstance($subject, $body);
             $message->addFrom(\GO::config()->noreply_email, \GO::config()->title);
             $message->addTo($userModel->email, $userModel->name);
             \GO\Base\Mail\Mailer::newGoInstance()->send($message, $failedRecipients);
             if (!empty($failedRecipients)) {
                 trigger_error("Reminder mail failed for recipient: " . implode(',', $failedRecipients), E_USER_NOTICE);
             }
             $reminderUserModelSend = \GO\Base\Model\ReminderUser::model()->findSingleByAttributes(array('user_id' => $userModel->id, 'reminder_id' => $reminderModel->id));
             $reminderUserModelSend->mail_sent = 1;
             $reminderUserModelSend->save();
         }
         date_default_timezone_set(\GO::user()->timezone);
     }
 }
Exemplo n.º 3
0
 /**
  * Get the table rows that need to be printed in the pdf
  * 
  * @return array
  */
 public function getRows()
 {
     if (empty($this->_rows)) {
         foreach ($this->calendars as $calendar) {
             $row = array('name' => $calendar->name);
             //				foreach($this->categories as $category){
             $findParams = \GO\Base\Db\FindParams::newInstance()->ignoreAcl()->select('COUNT(*) as count, category_id')->group('category_id');
             //					$findParams->ignoreAcl();							// Only count items that are visible for this user.
             //				$findParams->group('calendar_id');
             $findCriteria = \GO\Base\Db\FindCriteria::newInstance();
             $findCriteria->addCondition('calendar_id', $calendar->id);
             $findCriteria->addCondition('start_time', strtotime($this->startDate), '>');
             $findCriteria->addCondition('end_time', strtotime($this->endDate), '<');
             $findParams->criteria($findCriteria);
             $catRecord = array();
             foreach (Event::model()->find($findParams) as $record) {
                 $catRecord[intval($record->category_id)] = $record->count;
             }
             foreach ($this->categories as $category) {
                 $row[] = isset($catRecord[$category->id]) ? $catRecord[$category->id] : 0;
             }
             $this->_rows[] = $row;
         }
         //			}
     }
     return $this->_rows;
 }
Exemplo n.º 4
0
 /**
  * processStoreDelete
  *
  * @param $store
  * @param $params
  */
 protected function processStoreDelete($store, &$params)
 {
     if (isset($params['delete_keys'])) {
         $deleteRecords = json_decode($params['delete_keys'], true);
         $deleteRecords = array_filter($deleteRecords, 'intval');
         $criteria = FindCriteria::newInstance();
         $criteria->addCondition('default', 0);
         $criteria->addInCondition('id', $deleteRecords);
         $findParams = FindParams::newInstance()->criteria($criteria);
         $stmt = Label::model()->find($findParams);
         $deleteRecords = array();
         while ($label = $stmt->fetch()) {
             $deleteRecords[] = $label->getPk();
         }
         if (!count($deleteRecords)) {
             $params['delete_keys'] = '[]';
         } else {
             $params['delete_keys'] = json_encode($deleteRecords);
         }
     }
     $store->processDeleteActions($params, $this->model);
     if (isset($params['delete_keys']) && !count($params['delete_keys'])) {
         $store->response['deleteSuccess'] = true;
     }
 }
Exemplo n.º 5
0
 protected function getStoreParams($params)
 {
     $storeParams = \GO\Base\Db\FindParams::newInstance();
     $storeParams->getCriteria()->addCondition('model_name', $params['model_name']);
     $storeParams->select('t.*');
     return $storeParams;
 }
Exemplo n.º 6
0
 public static function checkIpAddress(array &$params, array &$response)
 {
     $oldIgnoreAcl = \GO::setIgnoreAclPermissions();
     $userModel = \GO\Base\Model\User::model()->findSingleByAttribute('username', $params['username']);
     if (!$userModel) {
         return true;
     }
     $allowedIpAddresses = array();
     //"127.0.0.1");
     $whitelistIpAddressesStmt = Model\IpAddress::model()->find(\GO\Base\Db\FindParams::newInstance()->select('t.ip_address')->joinModel(array('model' => 'GO\\Ipwhitelist\\Model\\EnableWhitelist', 'localTableAlias' => 't', 'localField' => 'group_id', 'foreignField' => 'group_id', 'tableAlias' => 'ew', 'type' => 'INNER'))->joinModel(array('model' => 'GO\\Base\\Model\\UserGroup', 'localTableAlias' => 'ew', 'localField' => 'group_id', 'foreignField' => 'group_id', 'tableAlias' => 'usergroup', 'type' => 'INNER'))->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('user_id', $userModel->id, '=', 'usergroup')));
     if (!empty($whitelistIpAddressesStmt) && $whitelistIpAddressesStmt->rowCount() > 0) {
         foreach ($whitelistIpAddressesStmt as $ipAddressModel) {
             //				$enabledWhitelistModel = Model\EnableWhitelist::model()->findByPk($groupModel->id);
             //				if (!empty($enabledWhitelistModel)) {
             //					$ipAddressesStmt = Model\IpAddress::model()->findByAttribute('group_id',$groupModel->id);
             //					foreach ($ipAddressesStmt as $ipAddressModel) {
             if (!in_array($ipAddressModel->ip_address, $allowedIpAddresses)) {
                 $allowedIpAddresses[] = $ipAddressModel->ip_address;
             }
             //					}
             //				}
         }
     }
     \GO::setIgnoreAclPermissions($oldIgnoreAcl);
     if (count($allowedIpAddresses) > 0 && !in_array($_SERVER['REMOTE_ADDR'], $allowedIpAddresses)) {
         $response['feedback'] = sprintf(\GO::t('wrongLocation', 'ipwhitelist'), $_SERVER['REMOTE_ADDR']);
         $response['success'] = false;
         return false;
     }
     return true;
 }
Exemplo n.º 7
0
 /**
  * Get the data for the grid that shows all the tasks from the selected tasklists.
  * 
  * @param Array $params
  * @return Array The array with the data for the grid. 
  */
 protected function actionBirthdays($params)
 {
     $today = mktime(0, 0, 0);
     $next_month = \GO\Base\Util\Date::date_add(mktime(0, 0, 0), 30);
     //\GO::debug($yesterday);
     $start = date('Y-m-d', $today);
     $end = date('Y-m-d', $next_month);
     //\GO::debug($start);
     $select = "t.id, birthday, first_name, middle_name, last_name, addressbook_id, photo, " . "IF (STR_TO_DATE(CONCAT(YEAR('{$start}'),'/',MONTH(birthday),'/',DAY(birthday)),'%Y/%c/%e') >= '{$start}', " . "STR_TO_DATE(CONCAT(YEAR('{$start}'),'/',MONTH(birthday),'/',DAY(birthday)),'%Y/%c/%e') , " . "STR_TO_DATE(CONCAT(YEAR('{$start}')+1,'/',MONTH(birthday),'/',DAY(birthday)),'%Y/%c/%e')) " . "as upcoming ";
     $findCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('birthday', '0000-00-00', '!=')->addRawCondition('birthday', 'NULL', 'IS NOT');
     $settings = \GO\Addressbook\Model\BirthdaysPortletSetting::model()->findByAttribute('user_id', \GO::user()->id);
     if (count($settings)) {
         $abooks = array_map(function ($value) {
             return $value->addressbook_id;
         }, $settings->fetchAll());
         $findCriteria->addInCondition('addressbook_id', $abooks);
     }
     $having = "upcoming BETWEEN '{$start}' AND '{$end}'";
     $findParams = \GO\Base\Db\FindParams::newInstance()->distinct()->select($select)->criteria($findCriteria)->having($having)->order('upcoming');
     //$response['data']['original_photo_url']=$model->photoURL;
     $columnModel = new \GO\Base\Data\ColumnModel('GO\\Addressbook\\Model\\Contact');
     $columnModel->formatColumn('addressbook_id', '$model->addressbook->name');
     $columnModel->formatColumn('photo_url', '$model->getPhotoThumbURL()');
     $columnModel->formatColumn('age', '($model->upcoming != date("Y-m-d")) ? $model->age+1 : $model->age');
     $store = new \GO\Base\Data\DbStore('GO\\Addressbook\\Model\\Contact', $columnModel, $_POST, $findParams);
     return $store->getData();
 }
Exemplo n.º 8
0
 protected function actionGroupsWithResources($params)
 {
     $stmt = \GO\Calendar\Model\Group::model()->find(\GO\Base\Db\FindParams::newInstance()->order('t.name')->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('id', 1, '>')));
     $response['results'] = array();
     $response['total'] = 0;
     while ($group = $stmt->fetch()) {
         $record = $group->getAttributes('formatted');
         if (\GO::modules()->customfields) {
             $record['customfields'] = \GO\Customfields\Controller\CategoryController::getEnabledCategoryData("GO\\Calendar\\Model\\Event", $group->id);
         } else {
             $record['customfields'] = array();
         }
         $record['resources'] = array();
         $calStmt = \GO\Calendar\Model\Calendar::model()->find(\GO\Base\Db\FindParams::newInstance()->permissionLevel(\GO\Base\Model\Acl::READ_PERMISSION)->joinCustomFields()->order('t.name')->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('group_id', $group->id)));
         while ($resource = $calStmt->fetch()) {
             $resourceRecord = $resource->getAttributes('formatted');
             $record['resources'][] = $resourceRecord;
         }
         $num_resources = count($record['resources']);
         if ($num_resources > 0) {
             $response['results'][] = $record;
             $response['total'] += $num_resources;
         }
     }
     return $response;
 }
Exemplo n.º 9
0
 protected function actionDisplay($params)
 {
     $findParams = \GO\Base\Db\FindParams::newInstance()->select('count(*) AS count')->join(\GO\Base\Model\ReminderUser::model()->tableName(), \GO\Base\Db\FindCriteria::newInstance()->addModel(\GO\Base\Model\Reminder::model())->addCondition('id', 'ru.reminder_id', '=', 't', true, true), 'ru')->criteria(\GO\Base\Db\FindCriteria::newInstance()->addModel(\GO\Base\Model\ReminderUser::model(), 'ru')->addCondition('user_id', \GO::user()->id, '=', 'ru')->addCondition('time', time(), '<', 'ru'));
     $model = \GO\Base\Model\Reminder::model()->findSingle($findParams);
     $html = "";
     $this->fireEvent('reminderdisplay', array($this, &$html, $params));
     $this->render("Reminder", array('count' => intval($model->count), 'html' => $html));
 }
Exemplo n.º 10
0
 /**
  * Loads a store of content items of the current website
  * 
  * @param int $id
  * @param int $site_id
  */
 public function actionContentStore($menu_id)
 {
     $menu = \GO\Site\Model\Menu::model()->findByPk($menu_id);
     $findCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('site_id', $menu->site_id);
     $findParams = \GO\Base\Db\FindParams::newInstance()->criteria($findCriteria);
     $store = new \GO\Base\Data\DbStore('GO\\Site\\Model\\Content', new \GO\Base\Data\ColumnModel('GO\\Site\\Model\\Content'), $_REQUEST, $findParams);
     echo $this->renderStore($store);
 }
Exemplo n.º 11
0
 protected function actionGetUsage($params)
 {
     $domains = json_decode($params['domains']);
     $response['success'] = true;
     $record = \GO\Postfixadmin\Model\Mailbox::model()->find(\GO\Base\Db\FindParams::newInstance()->single()->select('SUM(`usage`) AS `usage`')->joinModel(array('model' => 'GO\\Postfixadmin\\Model\\Domain', 'localField' => 'domain_id', 'tableAlias' => 'd'))->criteria(\GO\Base\Db\FindCriteria::newInstance()->addInCondition('domain', $domains, 'd')));
     $response['usage'] = $record->usage;
     return $response;
 }
Exemplo n.º 12
0
 /**
  * Loads a store of menu items that can be a parent of the given menu item.
  * 
  * @param int $id
  * @param int $site_id
  */
 public function actionParentStore($id = false, $menu_id)
 {
     $findCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('menu_id', $menu_id);
     $findCriteria->addCondition('id', $id, '<>');
     $findParams = \GO\Base\Db\FindParams::newInstance()->criteria($findCriteria);
     $store = new \GO\Base\Data\DbStore('GO\\Site\\Model\\MenuItem', new \GO\Base\Data\ColumnModel('GO\\Site\\Model\\MenuItem'), $_REQUEST, $findParams);
     echo $this->renderStore($store);
 }
Exemplo n.º 13
0
 protected function getStoreParams($params)
 {
     if (!empty($params['active'])) {
         return \GO\Base\Db\FindParams::newInstance()->select('t.*')->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('due_time', 0, '=', 't', false)->addCondition('due_time', mktime(0, 0, 0), '>=', 't', false))->order('id', 'DESC');
     } else {
         return \GO\Base\Db\FindParams::newInstance()->select('t.*');
     }
 }
Exemplo n.º 14
0
 protected function actionStore($params)
 {
     $groupId = $params['group_id'];
     $columnModel = new \GO\Base\Data\ColumnModel(\GO\Ipwhitelist\Model\IpAddress::model());
     $storeFindParams = \GO\Base\Db\FindParams::newInstance()->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('group_id', $groupId))->order('ip_address');
     $store = new \GO\Base\Data\DbStore('GO\\Ipwhitelist\\Model\\IpAddress', $columnModel, $params, $storeFindParams);
     echo $this->renderStore($store);
 }
Exemplo n.º 15
0
 /**
  * Execute a grouped query and return the statement. This class may be extended
  * so you can document loaded properties or implement additional functions.
  * 
  * @param string $modelName
  * @param array $groupBy eg array('t.name')
  * @param string $selectFields
  * @param \GO\Base\Db\FindParams $findParams
  * @return \GO\Base\Db\ActiveStatement
  */
 public function load($modelName, $groupBy, $selectFields, \GO\Base\Db\FindParams $findParams = null)
 {
     if (!isset($findParams)) {
         $findParams = \GO\Base\Db\FindParams::newInstance();
     }
     $findParams->ignoreAcl()->select($selectFields)->group($groupBy)->fetchClass(get_class($this));
     $stmt = \GO::getModel($modelName)->find($findParams);
     return $stmt;
 }
Exemplo n.º 16
0
 /**
  * Get enabled categories for a model.
  * 
  * @param string $modelName The name of the model that controls the disabled categories. eg. \GO\Addressbook\Model\Addressbook controls them for \GO\Addressbook\Model\Contact
  * @param int $modelId
  * @return array 
  */
 public function getEnabledIds($modelName, $modelId)
 {
     $stmt = $this->find(\GO\Base\Db\FindParams::newInstance()->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('model_name', $modelName)->addCondition('model_id', $modelId)));
     $ids = array();
     while ($enabled = $stmt->fetch()) {
         $ids[] = $enabled->category_id;
     }
     return $ids;
 }
Exemplo n.º 17
0
 protected function actionSelectStore($params)
 {
     $columnModel = new \GO\Base\Data\ColumnModel(\GO\Customfields\Model\Field::model());
     $columnModel->formatColumn('extends_model', '$model->category->extends_model', array(), 'category_id');
     $columnModel->formatColumn('full_info', '"[".\\GO::t($model->category->extends_model,"customfields")."] ".$model->category->name." : ".$model->name." (col_".$model->id.")"', array(), 'category_id');
     $findParams = \GO\Base\Db\FindParams::newInstance()->joinModel(array('model' => 'GO\\Customfields\\Model\\Category', 'localTableAlias' => 't', 'localField' => 'category_id', 'foreignField' => 'id', 'tableAlias' => 'c'))->criteria(\GO\Base\Db\FindCriteria::newInstance()->addInCondition('extends_model', array('GO\\Addressbook\\Model\\Contact', 'GO\\Addressbook\\Model\\Company', 'GO\\Projects2\\Model\\Project', 'GO\\Base\\Model\\User'), 'c')->addInCondition('datatype', array('GO\\Addressbook\\Customfieldtype\\Contact', 'GO\\Addressbook\\Customfieldtype\\Company'), 't'));
     $store = new \GO\Base\Data\DbStore('GO\\Customfields\\Model\\Field', $columnModel, $params, $findParams);
     echo $this->renderStore($store);
 }
Exemplo n.º 18
0
 /**
  * Get's the user's client state in a key value array.
  * 
  * @param int $user_id
  * @return array 
  */
 public function getFullClientState($user_id)
 {
     $state = array();
     $stmt = $this->findByAttribute('user_id', $user_id, \GO\Base\Db\FindParams::newInstance()->select('t.*'));
     while ($model = $stmt->fetch()) {
         $state[$model->name] = $model->value;
     }
     return $state;
 }
Exemplo n.º 19
0
 public function getGroupCalendars()
 {
     $findParams = \GO\Base\Db\FindParams::newInstance()->select('t.*')->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('view_id', $this->id, '=', 'vgr'));
     $findParams->joinModel(array('model' => 'GO\\Base\\Model\\User', 'localField' => 'user_id', 'tableAlias' => 'usr'));
     $findParams->joinModel(array('model' => 'GO\\Base\\Model\\UserGroup', 'localField' => 'user_id', 'foreignField' => 'user_id', 'tableAlias' => 'usg'));
     $findParams->joinModel(array('model' => 'GO\\Base\\Model\\Group', 'localField' => 'group_id', 'localTableAlias' => 'usg', 'tableAlias' => 'grp'));
     $findParams->joinModel(array('model' => 'GO\\Calendar\\Model\\ViewGroup', 'localField' => 'id', 'localTableAlias' => 'grp', 'foreignField' => 'group_id', 'tableAlias' => 'vgr', 'criteria' => \GO\Base\Db\FindCriteria::newInstance()->addCondition('view_id', $this->id, '=', 'vgr')));
     return Calendar::model()->find($findParams);
 }
Exemplo n.º 20
0
 public function actionSavedExportsStore($className)
 {
     $columnModel = new ColumnModel(SavedExport::model());
     // "t.name as text" needs to be added because this store is also used to create the menu. (And the menu expects the "text" property for it's label)
     $findParams = FindParams::newInstance()->select('t.*,t.name as text')->criteria(FindCriteria::newInstance()->addCondition('class_name', $className));
     $store = new DbStore('GO\\Base\\Model\\SavedExport', $columnModel, GO::request()->post, $findParams);
     $store->defaultSort = 'id';
     echo $this->render('store', array('store' => $store));
 }
Exemplo n.º 21
0
 private function _getLastMtime($user_id)
 {
     Folder::model()->addRelation('aclItem', array("type" => self::BELONGS_TO, "model" => "GO\\Base\\Model\\Acl", "field" => 'acl_id'));
     $findParams = \GO\Base\Db\FindParams::newInstance()->debugSql()->select("max(a.mtime) AS mtime")->single()->joinModel(array('model' => "GO\\Base\\Model\\Acl", 'localField' => 'acl_id', 'tableAlias' => 'a'));
     $findParams->getCriteria()->addModel(Folder::model())->addCondition('visible', 1);
     //						->addCondition('user_id', $user_id, '!=');
     $result = Folder::model()->find($findParams);
     return $result->mtime;
 }
Exemplo n.º 22
0
 /**
  * Returns the latest Announcement model that user $userId has at least read
  * permission to.
  * @param Integer $userId
  * @return \GO\Summary\Model\Announcement or false
  */
 private static function _getLatestAnnouncement($userId)
 {
     $announcementsStmt = Announcement::model()->find(\GO\Base\Db\FindParams::newInstance()->permissionLevel(\GO\Base\Model\Acl::READ_PERMISSION, $userId)->order('ctime', 'DESC'));
     if (!empty($announcementsStmt) && $announcementsStmt->rowCount() > 0) {
         return $announcementsStmt->fetch();
     } else {
         return false;
     }
 }
Exemplo n.º 23
0
 public static function head()
 {
     echo '<style>';
     $findParams = \GO\Base\Db\FindParams::newInstance()->joinRelation('category')->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('behave_as_module', 1)->addCondition('show_in_startmenu', 1, '=', 'category', false));
     $stmt = Model\Bookmark::model()->find($findParams);
     while ($bookmark = $stmt->fetch()) {
         echo '.go-menu-icon-bookmarks-id-' . $bookmark->id . '{background-image:url(' . $bookmark->thumbUrl . ')}';
     }
     echo '</style>';
 }
Exemplo n.º 24
0
 /**
  * Returns an array with all the child nodes
  *
  * @return Sabre\DAV\INode[]
  */
 public function getChildren()
 {
     \GO::debug('Shared::getChildren()');
     $shares = \GO\Files\Model\Folder::model()->getTopLevelShares(\GO\Base\Db\FindParams::newInstance()->limit(100));
     $nodes = array();
     foreach ($shares as $folder) {
         $nodes[] = new \GO\DAV\FS\Directory($folder->path);
     }
     return $nodes;
 }
Exemplo n.º 25
0
 protected function defaultAttributes()
 {
     $attr = parent::defaultAttributes();
     $findParams = \GO\Base\Db\FindParams::newInstance()->limit(1);
     $stmt = Template::model()->find($findParams);
     if ($template = $stmt->fetch()) {
         $attr['template_id'] = $template->id;
     }
     return $attr;
 }
Exemplo n.º 26
0
 /**
  * This function will be called when the $config['smtp_account_id'] is set in the Group-Office config file.
  * If the account cannot be found then this function will return an exception
  * 
  * @throws \GO\Base\Exception\NotFound
  */
 private function _setAccount()
 {
     $findParams = \GO\Base\Db\FindParams::newInstance()->ignoreAcl();
     $this->_account = \GO\Email\Model\Account::model()->findByPk(\GO::config()->smtp_account_id, $findParams, true);
     if (!$this->_account) {
         throw new \GO\Base\Exception\NotFound('The mailaccount given in the Group-Office config file cannot be found');
     }
     $this->_alias = $this->_account->defaultAlias;
     $this->setFrom($this->_alias->email, $this->_alias->name);
 }
Exemplo n.º 27
0
 protected function getStoreParams($params)
 {
     if (empty($params['account_id'])) {
         $findParams = \GO\Base\Db\FindParams::newInstance()->select('t.*')->joinModel(array('model' => 'GO\\Email\\Model\\AccountSort', 'foreignField' => 'account_id', 'localField' => 'account_id', 'type' => 'LEFT', 'tableAlias' => 'sor', "criteria" => \GO\Base\Db\FindCriteria::newInstance()->addCondition('user_id', \GO::user()->id, "=", 'sor')))->ignoreAdminGroup()->permissionLevel(\GO\Base\Model\Acl::CREATE_PERMISSION)->order(array('order', 'default'), array('DESC', 'DESC'));
     } else {
         $findParams = \GO\Base\Db\FindParams::newInstance();
         $findParams->getCriteria()->addCondition("account_id", $params['account_id'])->addCondition("default", 1, '!=');
     }
     return $findParams;
 }
Exemplo n.º 28
0
 public function formatRawOutput($key, &$attributes, \GO\Customfields\Model\AbstractCustomFieldsRecord $model)
 {
     $column = $model->getColumn($key);
     if (!$column) {
         return null;
     }
     $fieldId = $column['customfield']->id;
     $findParams = \GO\Base\Db\FindParams::newInstance()->ignoreAcl()->order('mf.order')->joinModel(array('model' => 'GO\\Site\\Model\\MultifileFile', 'localTableAlias' => 't', 'localField' => 'id', 'foreignField' => 'file_id', 'tableAlias' => 'mf'))->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('model_id', $model->model_id, '=', 'mf')->addCondition('field_id', $fieldId, '=', 'mf'));
     return \GO\Files\Model\File::model()->find($findParams, 'false', true);
 }
 public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0)
 {
     $users = array();
     $group = \GO\Base\Model\Group::model()->findSingleByAttribute('name', $gid);
     $findParams = \GO\Base\Db\FindParams::newInstance()->start($offset)->limit($limit)->searchQuery($search);
     $stmt = $group->users($findParams);
     foreach ($stmt as $user) {
         $users[] = $user->username;
     }
     return $users;
 }
Exemplo n.º 30
0
 /**
  * Search through the site content
  * 
  * @param array $params
  * @throws Exception
  */
 protected function actionSearch($params)
 {
     if (!isset($params['searchString'])) {
         throw new \Exception('No searchstring provided');
     }
     $searchString = $params['searchString'];
     $searchParams = \GO\Base\Db\FindParams::newInstance()->select('*')->criteria(\GO\Base\Db\FindCriteria::newInstance()->addSearchCondition('title', $searchString, false)->addSearchCondition('meta_title', $searchString, false)->addSearchCondition('meta_description', $searchString, false)->addSearchCondition('meta_keywords', $searchString, false)->addSearchCondition('content', $searchString, false));
     $columnModel = new \GO\Base\Data\ColumnModel();
     $store = new \GO\Base\Data\DbStore('GO\\Site\\Model\\Content', $columnModel, $params, $searchParams);
     echo $this->render('search', array('searchResults' => $store));
 }