本文整理汇总了PHP中GO\Base\Db\FindParams类的典型用法代码示例。如果您正苦于以下问题:PHP FindParams类的具体用法?PHP FindParams怎么用?PHP FindParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FindParams类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* 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();
}
}
示例2: run
/**
* 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);
}
}
示例3: getRows
/**
* 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;
}
示例4: processStoreDelete
/**
* 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;
}
}
示例5: getStoreParams
protected function getStoreParams($params)
{
$storeParams = \GO\Base\Db\FindParams::newInstance();
$storeParams->getCriteria()->addCondition('model_name', $params['model_name']);
$storeParams->select('t.*');
return $storeParams;
}
示例6: checkIpAddress
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;
}
示例7: actionBirthdays
/**
* 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();
}
示例8: actionGroupsWithResources
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;
}
示例9: actionDisplay
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));
}
示例10: actionContentStore
/**
* 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);
}
示例11: actionGetUsage
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;
}
示例12: actionParentStore
/**
* 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);
}
示例13: getStoreParams
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.*');
}
}
示例14: actionStore
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);
}
示例15: load
/**
* 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;
}