/** * Tests the recovery of internal objects value. */ public function testInvokeResult() { $objects = new Objects(); $objects[0] = new resources\foo(); $objects[1] = new resources\foo(); $this->assertSame(array('foo from foo', 'foo from foo'), $objects->invoke('getFoo')); }
public function indexAction() { $objectsTable = new Objects(); #$objectsTable->createRowAsFirstChild(3,array('title'=>'nowy')); #$objectsTable->createRowAfterNode(5,array('title'=>'nowy test')); #$objectsTable->find(19)->current()->delete(); $this->view->tree = $objectsTable->fetchFullTree(); }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { // $cats = Category::model()->findAll(array('condition'=>'lft=1 and rgt=2 and level=1','order'=>'title')); $this->pageTitle = 'Быстрые отзывы покупателей о товарах и услугах'; $cats = Category::getRubsByParentId(); $lasts = Objects::model()->active()->findAll(array('order' => 'created_date DESC', 'limit' => 15)); $last_array = array(); if (!empty($lasts)) { foreach ($lasts as $last) { $last_array[] = $last->id; } } /* $criteria = new CDbCriteria; $criteria->order = 'created_date DESC'; $criteria->limit = 3; $criteria->addNotInCondition('org_id', $last_array); $lasts_poll = PollChoice::model()->findAll($criteria); if(!empty($lasts_poll)){ foreach ($lasts_poll as $last_poll) { if(!in_array($last_poll->org->id, $last_array)){ $last_array[] = $last_poll->org->id; $lasts[] = $last_poll->org; } } } */ $this->render('index', array('cats' => $cats, 'lasts' => $lasts)); }
public function rebuild($start_date = null, $end_date = null) { if (!$start_date) { $start_date = config_option('last_sharing_table_rebuild'); } if ($start_date instanceof DateTimeValue) { $start_date = $start_date->toMySQL(); } if ($end_date instanceof DateTimeValue) { $end_date = $end_date->toMySQL(); } if ($end_date) { $end_cond = "AND updated_on <= '{$end_date}'"; } try { $object_ids = Objects::instance()->findAll(array('id' => true, "conditions" => "updated_on >= '{$start_date}' {$end_cond}")); $obj_count = 0; DB::beginWork(); foreach ($object_ids as $id) { $obj = Objects::findObject($id); if ($obj instanceof ContentDataObject) { $obj->addToSharingTable(); $obj_count++; } } set_config_option('last_sharing_table_rebuild', DateTimeValueLib::now()->toMySQL()); DB::commit(); } catch (Exception $e) { DB::rollback(); Logger::log("Failed to rebuild sharing table: " . $e->getMessage() . "\nTrace: " . $e->getTraceAsString()); } return $obj_count; }
function purge_trash() { Env::useHelper("permissions"); $days = config_option("days_on_trash", 0); $count = 0; if ($days > 0) { $date = DateTimeValueLib::now()->add("d", -$days); $objects = Objects::findAll(array("conditions" => array("`trashed_by_id` > 0 AND `trashed_on` < ?", $date), "limit" => 100)); foreach ($objects as $object) { $concrete_object = Objects::findObject($object->getId()); if (!$concrete_object instanceof ContentDataObject) { continue; } if ($concrete_object instanceof MailContent && $concrete_object->getIsDeleted() > 0) { continue; } try { DB::beginWork(); if ($concrete_object instanceof MailContent) { $concrete_object->delete(false); } else { $concrete_object->delete(); } ApplicationLogs::createLog($concrete_object, ApplicationLogs::ACTION_DELETE); DB::commit(); $count++; } catch (Exception $e) { DB::rollback(); Logger::log("Error delting object in purge_trash: " . $e->getMessage(), Logger::ERROR); } } } return $count; }
/** * Return object * * @param void * @return ApplicationDataObject */ function getObject() { if (is_null($this->object)) { $this->object = Objects::findObject($this->getObjectId()); } return $this->object; }
/** * Return object connected with this action, that is not equal to the one received * * @access public * @param ProjectDataObject $object * @return ProjectDataObject */ function getOtherObject($object) { if (($object->getObjectId()!= $this->getObjectId()) ) { return Objects::findObject($this->getObjectId()); } else { return Objects::findObject($this->getRelObjectId()); } } // getObject
function mail_do_mark_as_read_unread_objects($ids_to_mark, $read) { $all_accounts = array(); $all_accounts_ids = array(); foreach ($ids_to_mark as $id) { $obj = Objects::findObject($id); if ($obj instanceof MailContent && logged_user() instanceof Contact) { //conversation set the rest of the conversation $uds_to_mark_from_conver = array(); if (user_config_option('show_emails_as_conversations')) { $emails_in_conversation = MailContents::getMailsFromConversation($obj); foreach ($emails_in_conversation as $email) { //$id is marked on object controller only mark the rest of the conversation if ($id != $email->getId()) { $email->setIsRead(logged_user()->getId(), $read); $uds_to_mark_from_conver[] = $email->getUid(); } } } //make the array with accounts and uids to send to the mail server //accounts if (!in_array($obj->getAccountId(), $all_accounts_ids)) { $account = $obj->getAccount(); //if logged user is owner of this account and is imap if ($account instanceof MailAccount && $account->getContactId() == logged_user()->getId() && $account->getIsImap()) { $all_accounts_ids[] = $obj->getAccountId(); $all_accounts[$account->getId()]['account'] = $account; } } //uids if (in_array($obj->getAccountId(), $all_accounts_ids)) { //add conversations uids //mientras ande mal el uid de los mails enviados si estan sincronizados no usar esta parte /*if (user_config_option('show_emails_as_conversations')) { foreach ($uds_to_mark_from_conver as $uid_conver){ $all_accounts[$obj->getAccountId()]['uids'][] = $uid_conver; } }*/ $all_accounts[$obj->getAccountId()]['folders'][$obj->getImapFolderName()][] = $obj->getUid(); } } } //foreach account send uids by folder to mark in the mail server foreach ($all_accounts as $account_data) { $account = $account_data['account']; $folders = $account_data['folders']; foreach ($folders as $key => $folder) { $folder_name = $key; $uids = $folder; if (!empty($folder_name)) { try { MailUtilities::setReadUnreadImapMails($account, $folder_name, $uids, $read); } catch (Exception $e) { Logger::log("Could not set mail as read on mail server, exception:\n" . $e->getMessage()); } } } } }
public static function collectProperties($objects, $properties, $defaults = null) { $output = array(); foreach ($objects as $object) { foreach ($properties as $property) { $output[] = Objects::get($object, $property, $defaults[$property]); } } return $output; }
public static function &get($var, $name, $default = null) { if (is_array($var)) { return Arrays::get($var, $name, $default); } if (is_object($var)) { return Objects::get($var, $name, $default); } throw new Exception("\$var must be either an array or object"); }
/** * Returns all Objects of a Template * * @param integer $template_id * @return array */ static function getObjectsByTemplate($template_id) { $all = self::findAll(array('conditions' => array('`template_id` = ?', $template_id) )); if (!is_array($all)) return array(); $objs = array(); foreach ($all as $obj) { $objs[] = Objects::findObject($obj->getObjectId()); } return $objs; }
/** * Connect object properties by chaining it like a.b.c... * @param $sPropertyChain * @param $oObject * @return bool */ public static function property_chain($sPropertyChain, $oObject) { $sPropertyChain = explode('.', $sPropertyChain); foreach ($sPropertyChain as $sElement) { $oObject = Objects::property($sElement, $oObject); if (!$oObject) { return false; } } return $oObject; }
/** * @todo this will incorrectly evaluate isSelected() as true if the model object is null * and the choice render returns a 0 * @param type $choice * @param type $index * @return type */ public function isSelected($choice, $index) { if ($this->isEmptyInput()) { return false; } else { $raw = $this->getRawInput(); if (!empty($raw)) { return $this->getRawInput() == $this->getChoiceRenderer()->getValue($choice, $index); } else { return Objects::equals($this->getModelObject(), $choice); } } }
private static function stringifyArrayElements($array) { $elements = array(); $isAssociative = array_keys($array) !== range(0, sizeof($array) - 1); array_walk($array, function ($element, $key) use(&$elements, $isAssociative) { if ($isAssociative) { $elements[] = "<{$key}> => " . Objects::toString($element); } else { $elements[] = Objects::toString($element); } }); return $elements; }
function healPermissionGroup(SharingTableFlag $flag) { if ($flag->getObjectId() > 0) { try { $obj = Objects::findObject($flag->getObjectId()); if (!$obj instanceof ContentDataObject) { $flag->delete(); // if object does not exists then delete the flag return; } DB::beginWork(); // update sharing table $obj->addToSharingTable(); DB::commit(); } catch (Exception $e) { DB::rollback(); Logger::log("Failed to heal object permissions for object " . $flag->getObjectId() . " (flag_id = " . $flag->getId() . ")"); return false; } // delete flag $flag->delete(); return true; } else { // heal $controller = new SharingTableController(); $permissions_string = $flag->getPermissionString(); $permission_group_id = $flag->getPermissionGroupId(); $permissions = json_decode($permissions_string); if ($flag->getMemberId() > 0) { foreach ($permissions as $p) { if (!isset($p->m)) { $p->m = $flag->getMemberId(); } } } try { DB::beginWork(); // update sharing table $controller->afterPermissionChanged($permission_group_id, $permissions); DB::commit(); } catch (Exception $e) { DB::rollback(); Logger::log("Failed to heal permission group {$permission_group_id} (flag_id = " . $flag->getId() . ")\n" . $e->getTraceAsString()); return false; } // delete flag $flag->delete(); return true; } }
/** * Returns all Objects of a Template * * @param integer $template_id * @return array */ static function getObjectsByTemplate($template_id) { $all = self::findAll(array('conditions' => array('`template_id` = ?', $template_id))); if (!is_array($all)) { return array(); } $objs = array(); foreach ($all as $obj) { $o = Objects::findObject($obj->getObjectId()); if ($o instanceof ContentDataObject) { $objs[] = $o; } } return $objs; }
public function actionIndex() { $this->active_link = 'dashboard'; //count users $users = User::model()->count('status != '.User::STATUS_DELETED); $objects = Objects::model()->active()->count(array('select'=>'id')); $objectsNew = Objects::model()->active()->count(array('select'=>'id','condition'=>'verified = false')); $polls = PollChoice::model()->count(); $photos = ObjectsImages::model()->count(); $videos = ObjectsHttp::model()->count(array('condition'=>'type='.ObjectsHttp::TYPE_VIDEO)); $this->render('dashboard',array('users'=>$users,'objects'=>$objects, 'objectsNew'=>$objectsNew, 'polls'=>$polls,'photos'=>$photos, 'videos'=>$videos )); }
public function getName($id = false) { if ($id === false) { $id = $this->id; } $rez = $id; switch ($id) { case 'recent': case 'commented': case 'modified': case 'added': return L\get(ucfirst($id)); default: $rez = Objects::getName($id); break; } return $rez; }
/** * * */ public function activity_feed() { ajx_set_no_back(true); require_javascript("og/modules/dashboardComments.js"); require_javascript("jquery/jquery.scrollTo-min.js"); $filesPerPage = config_option('files_per_page'); $start = array_var($_GET, 'start') ? (int) array_var($_GET, 'start') : 0; $limit = array_var($_GET, 'limit') ? array_var($_GET, 'limit') : $filesPerPage; $order = array_var($_GET, 'sort'); $orderdir = array_var($_GET, 'dir'); $page = (int) ($start / $limit) + 1; $extra_conditions = " AND jt.type IN ('content_object', 'comment')"; $trashed = array_var($_GET, 'trashed', false); $archived = array_var($_GET, 'archived', false); $pagination = ContentDataObjects::listing(array("start" => $start, "limit" => $limit, "order" => $order, "order_dir" => $orderdir, "trashed" => $trashed, "archived" => $archived, "count_results" => false, "extra_conditions" => $extra_conditions, "join_params" => array("jt_field" => "id", "e_field" => "object_type_id", "table" => TABLE_PREFIX . "object_types"))); $result = $pagination->objects; $total_items = $pagination->total; if (!$result) { $result = array(); } $info = array(); foreach ($result as $obj) { $info_elem = $obj->getArrayInfo($trashed, $archived); $instance = Objects::instance()->findObject($info_elem['object_id']); $info_elem['url'] = $instance->getViewUrl(); if (method_exists($instance, "getText")) { $info_elem['content'] = $instance->getText(); } $info_elem['picture'] = $instance->getCreatedBy()->getPictureUrl(); $info_elem['friendly_date'] = friendly_date($instance->getCreatedOn()); $info_elem['comment'] = $instance->getComments(); if ($instance instanceof Contact) { if ($instance->isCompany()) { $info_elem['icon'] = 'ico-company'; $info_elem['type'] = 'company'; } } $info_elem['isRead'] = $instance->getIsRead(logged_user()->getId()); $info_elem['manager'] = get_class($instance->manager()); $info[] = $info_elem; } $listing = array("totalCount" => $total_items, "start" => $start, "objects" => $info); tpl_assign("feeds", $listing); }
function workspaces_quickadd_extra_fields($parameters) { if (array_var($parameters, 'dimension_id') == Dimensions::findByCode("workspaces")->getId()) { $parent_member = Members::findById(array_var($parameters, 'parent_id')); if ($parent_member instanceof Member && $parent_member->getObjectId() > 0) { $dimension_object = Objects::findObject($parent_member->getObjectId()); $fields = $dimension_object->manager()->getPublicColumns(); $color_columns = array(); foreach ($fields as $f) { if ($f['type'] == DATA_TYPE_WSCOLOR) { $color_columns[] = $f['col']; } } foreach ($color_columns as $col) { foreach ($fields as &$f) { if ($f['col'] == $col && $dimension_object->columnExists($col)) { $color_code = $dimension_object->getColumnValue($col); echo '<input type="hidden" name="dim_obj['.$col.']" value="'.$color_code.'" />'; } } } } } }
<?php echo '<div class="">'; $num = substr($data['id'], 0, 1); $id = substr_replace($data['id'], '', 0, 1); $id = (int) $id; if ($num == 2) { $data['uploaded_by'] = $this->user->id; $bl = $this->renderPartial('_lastimages', array('model' => $data, 'addClass' => 'col-sm-3 col-xs-6'), true); } elseif ($num == 1) { $comment = Comment::model()->with('obj')->findByPk($id); $bl = $this->renderPartial('_itemmain', array('model' => $comment, 'org' => $comment->obj), true); } else { $object = Objects::model()->findByPk($id); $bl = $this->renderPartial('_objects_view', array('data' => $object), true); } echo $bl; echo '</div>';
/** * Add comment * * Through this controller only logged users can post (no anonymous comments here) * * @param void * @return null */ function add() { $this->setTemplate('add_comment'); $object_id = get_id('object_id'); $object = Objects::findObject($object_id); if (!$object instanceof ContentDataObject) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $comment = new Comment(); $comment_data = array_var($_POST, 'comment'); tpl_assign('comment_form_object', $object); tpl_assign('comment', $comment); tpl_assign('comment_data', $comment_data); if (is_array($comment_data)) { try { try { $attached_files = ProjectFiles::handleHelperUploads(active_context()); } catch (Exception $e) { $attached_files = null; } // try $comment->setFromAttributes($comment_data); $comment->setRelObjectId($object_id); $comment->setObjectName(substr_utf($comment->getText(), 0, 250)); DB::beginWork(); $comment->save(); $comment->addToMembers($object->getMembers()); if (is_array($attached_files)) { foreach ($attached_files as $attached_file) { $comment->attachFile($attached_file); } // foreach } // if // Subscribe user to object if (!$object->isSubscriber(logged_user())) { $object->subscribeUser(logged_user()); } // if if (strlen($comment->getText()) < 100) { $comment_head = $comment->getText(); } else { $lastpos = strpos($comment->getText(), " ", 100); if ($lastpos === false) { $comment_head = $comment->getText(); } else { $comment_head = substr($comment->getText(), 0, $lastpos) . "..."; } } $comment_head = html_to_text($comment_head); ApplicationLogs::createLog($comment, ApplicationLogs::ACTION_COMMENT, false, false, true, $comment_head); DB::commit(); flash_success(lang('success add comment')); ajx_current("reload"); } catch (Exception $e) { DB::rollback(); ajx_current("empty"); flash_error($e->getMessage()); } // try } // if }
/** * Used for Drag & Drop, adds objects to a member * @author alvaro */ function add_objects_to_member() { $ids = json_decode(array_var($_POST, 'objects')); $mem_id = array_var($_POST, 'member'); if (!is_array($ids) || count($ids) == 0) { ajx_current("empty"); return; } $member = Members::findById($mem_id); try { DB::beginWork(); $objects = array(); $from = array(); foreach ($ids as $oid) { /* @var $obj ContentDataObject */ $obj = Objects::findObject($oid); $dim_obj_type_content = DimensionObjectTypeContents::findOne(array('conditions' => array('`dimension_id`=? AND `dimension_object_type_id`=? AND `content_object_type_id`=?', $member->getDimensionId(), $member->getObjectTypeId(), $obj->getObjectTypeId()))); if (!$dim_obj_type_content instanceof DimensionObjectTypeContent) { continue; } if (!$dim_obj_type_content->getIsMultiple() || array_var($_POST, 'remove_prev')) { $db_res = DB::execute("SELECT group_concat(om.member_id) as old_members FROM " . TABLE_PREFIX . "object_members om INNER JOIN " . TABLE_PREFIX . "members m ON om.member_id=m.id WHERE m.dimension_id=" . $member->getDimensionId() . " AND om.object_id=" . $obj->getId()); $row = $db_res->fetchRow(); if (array_var($row, 'old_members') != "") { $from[$obj->getId()] = $row['old_members']; } // remove from previous members ObjectMembers::delete('`object_id` = ' . $obj->getId() . ' AND `member_id` IN (SELECT `m`.`id` FROM `' . TABLE_PREFIX . 'members` `m` WHERE `m`.`dimension_id` = ' . $member->getDimensionId() . ')'); } $obj->addToMembers(array($member)); $obj->addToSharingTable(); $objects[] = $obj; } DB::commit(); // add to application logs foreach ($objects as $object) { $action = array_var($from, $obj->getId()) ? ApplicationLogs::ACTION_MOVE : ApplicationLogs::ACTION_COPY; $log_data = (array_var($from, $obj->getId()) ? "from:" . array_var($from, $obj->getId()) . ";" : "") . "to:" . $member->getId(); ApplicationLogs::instance()->createLog($object, $action, false, true, true, $log_data); } $lang_key = count($ids) > 1 ? 'objects moved to member success' : 'object moved to member success'; flash_success(lang($lang_key, $member->getName())); if (array_var($_POST, 'reload')) { ajx_current('reload'); } else { ajx_current('empty'); } } catch (Exception $e) { DB::rollback(); ajx_current("empty"); flash_error(lang('unable to move objects')); } }
function findById($id, $force_reload = false) { $co = parent::findById($id, $force_reload); if (!is_null($co)) { $co->setObject(Objects::findById($id, $force_reload)); } return $co; }
function preludesB() { global $FF, $MSIE, $leftmenu, $topmenu, $thisYear, $thisMonth, $thisDay, $DSOcatalogsLists, $DSOcatalogs, $objAstroCalc, $objAtlas, $objCatalog, $objCometObject, $objCometObservation, $objConstellation, $objContrast, $objDatabase, $objEyepiece, $objFilter, $objFormLayout, $objInstrument, $objLanguage, $objLens, $objList, $objLocation, $objObject, $objObjectOutlines, $objObservation, $objObserverQueries, $objObserver, $objPresentations, $objPrintAtlas, $objReportLayout, $objStar, $objAccomplishments, $objUtil; require_once "lib/observerqueries.php"; $objObserverQueries = new Observerqueries(); require_once "lib/atlasses.php"; $objAtlas = new Atlasses(); require_once "lib/locations.php"; $objLocation = new Locations(); require_once "lib/instruments.php"; $objInstrument = new Instruments(); require_once "lib/filters.php"; $objFilter = new Filters(); require_once "lib/lenses.php"; $objLens = new Lenses(); require_once "lib/contrast.php"; $objContrast = new Contrast(); require_once "lib/eyepieces.php"; $objEyepiece = new Eyepieces(); require_once "lib/observations.php"; $objObservation = new Observations(); require_once "lib/accomplishments.php"; $objAccomplishments = new Accomplishments(); require_once "lib/lists.php"; $objList = new Lists(); require_once "lib/objects.php"; $objObject = new Objects(); require_once "lib/objectOutlines.php"; $objObjectOutlines = new ObjectOutlines(); include_once "lib/astrocalc.php"; $objAstroCalc = new AstroCalc(); require_once "lib/stars.php"; $objStar = new Stars(); include_once "lib/cometobservations.php"; $objCometObservation = new cometObservations(); include_once "lib/cometobjects.php"; $objCometObject = new CometObjects(); include_once 'lib/presentation.php'; $objPresentations = new Presentations(); include_once 'lib/constellations.php'; $objConstellation = new Constellation(); include_once 'lib/formlayouts.php'; $objFormLayout = new formLayouts(); include_once 'lib/reportlayouts.php'; $objReportLayout = new reportLayouts(); include_once 'lib/catalogs.php'; $objCatalog = new catalogs(); include_once "lib/moonphase.inc.php"; include_once "lib/printatlas.php"; $objPrintAtlas = new PrintAtlas(); include_once "lib/class.pdf.php"; include_once "lib/class.ezpdf.php"; include_once "lib/icqmethod.php"; include_once "lib/icqreferencekey.php"; if (strpos($browser = $objUtil->checkArrayKey($_SERVER, 'HTTP_USER_AGENT', ''), 'Firefox') === false) { $FF = false; } else { $FF = true; } if (strpos($browser = $objUtil->checkArrayKey($_SERVER, 'HTTP_USER_AGENT', ''), 'MSIE') === false) { $MSIE = false; } else { $MSIE = true; } if (array_key_exists('globalMonth', $_SESSION) && $_SESSION['globalMonth']) { } else { $_SESSION['globalYear'] = $thisYear; $_SESSION['globalMonth'] = $thisMonth; $_SESSION['globalDay'] = $thisDay; } if (array_key_exists('changeMonth', $_GET) && $_GET['changeMonth']) { $_SESSION['globalMonth'] = $_GET['changeMonth']; if ($_SESSION['globalDay'] > 28 && $_SESSION['globalMonth'] == 2) { $_SESSION['globalDay'] = 28; } if ($_SESSION['globalDay'] == 31 && ($_SESSION['globalMonth'] == 4 || $_SESSION['globalMonth'] == 6 || $_SESSION['globalMonth'] == 9 || $_SESSION['globalMonth'] == 11)) { $_SESSION['globalDay'] = 30; } if (array_key_exists('Qobj', $_SESSION)) { $_SESSION['Qobj'] = $objObject->getObjectRisSetTrans($_SESSION['Qobj']); } } if (array_key_exists('changeYear', $_GET) && $_GET['changeYear']) { $_SESSION['globalYear'] = $_GET['changeYear']; if (array_key_exists('Qobj', $_SESSION)) { $_SESSION['Qobj'] = $objObject->getObjectRisSetTrans($_SESSION['Qobj']); } } if (array_key_exists('changeDay', $_GET) && $_GET['changeDay']) { $_SESSION['globalDay'] = $_GET['changeDay']; if (array_key_exists('Qobj', $_SESSION)) { $_SESSION['Qobj'] = $objObject->getObjectRisSetTrans($_SESSION['Qobj']); } } if (array_key_exists('leftmenu', $_GET)) { $leftmenu = $_GET['leftmenu']; } elseif (array_key_exists('leftmenu', $_COOKIE)) { $leftmenu = $_COOKIE['leftmenu']; } if (array_key_exists('topmenu', $_GET)) { $topmenu = $_GET['topmenu']; } elseif (array_key_exists('topmenu', $_COOKIE)) { $topmenu = $_COOKIE['topmenu']; } $DSOcatalogsLists = $objObject->getCatalogsAndLists(); $DSOcatalogs = $objObject->getCatalogs(); }
/** * Execute a report and return results * * @param $id * @param $params * * @return array */ static function executeReport($id, $params, $order_by_col = '', $order_by_asc = true, $offset = 0, $limit = 50, $to_print = false) { if (is_null(active_context())) { CompanyWebsite::instance()->setContext(build_context_array(array_var($_REQUEST, 'context'))); } $results = array(); $report = self::getReport($id); $show_archived = false; if ($report instanceof Report) { $conditionsFields = ReportConditions::getAllReportConditionsForFields($id); $conditionsCp = ReportConditions::getAllReportConditionsForCustomProperties($id); $ot = ObjectTypes::findById($report->getReportObjectTypeId()); $table = $ot->getTableName(); if ($ot->getType() == 'dimension_object' || $ot->getType() == 'dimension_group') { $hook_parameters = array('report' => $report, 'params' => $params, 'order_by_col' => $order_by_col, 'order_by_asc' => $order_by_asc, 'offset' => $offset, 'limit' => $limit, 'to_print' => $to_print); $report_result = null; Hook::fire('replace_execute_report_function', $hook_parameters, $report_result); if ($report_result) { return $report_result; } } eval('$managerInstance = ' . $ot->getHandlerClass() . "::instance();"); eval('$item_class = ' . $ot->getHandlerClass() . '::instance()->getItemClass(); $object = new $item_class();'); $order_by = ''; if (is_object($params)) { $params = get_object_vars($params); } $report_columns = ReportColumns::getAllReportColumns($id); $allConditions = ""; $contact_extra_columns = self::get_extra_contact_columns(); if (count($conditionsFields) > 0) { foreach ($conditionsFields as $condField) { if ($condField->getFieldName() == "archived_on") { $show_archived = true; } $skip_condition = false; $model = $ot->getHandlerClass(); $model_instance = new $model(); $col_type = $model_instance->getColumnType($condField->getFieldName()); $allConditions .= ' AND '; $dateFormat = 'm/d/Y'; if (isset($params[$condField->getId()])) { $value = $params[$condField->getId()]; if ($col_type == DATA_TYPE_DATE || $col_type == DATA_TYPE_DATETIME) { $dateFormat = user_config_option('date_format'); } } else { $value = $condField->getValue(); } if ($ot->getHandlerClass() == 'Contacts' && in_array($condField->getFieldName(), $contact_extra_columns)) { $allConditions .= self::get_extra_contact_column_condition($condField->getFieldName(), $condField->getCondition(), $value); } else { if ($value == '' && $condField->getIsParametrizable()) { $skip_condition = true; } if (!$skip_condition) { $field_name = $condField->getFieldName(); if (in_array($condField->getFieldName(), Objects::getColumns())) { $field_name = 'o`.`' . $condField->getFieldName(); } if ($condField->getCondition() == 'like' || $condField->getCondition() == 'not like') { $value = '%' . $value . '%'; } if ($col_type == DATA_TYPE_DATE || $col_type == DATA_TYPE_DATETIME) { if ($value == date_format_tip($dateFormat)) { $value = EMPTY_DATE; } else { $dtValue = DateTimeValueLib::dateFromFormatAndString($dateFormat, $value); $value = $dtValue->format('Y-m-d'); } } if ($condField->getCondition() != '%') { if ($col_type == DATA_TYPE_INTEGER || $col_type == DATA_TYPE_FLOAT) { $allConditions .= '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value); } else { if ($condField->getCondition() == '=' || $condField->getCondition() == '<=' || $condField->getCondition() == '>=') { if ($col_type == DATA_TYPE_DATETIME || $col_type == DATA_TYPE_DATE) { $equal = 'datediff(' . DB::escape($value) . ', `' . $field_name . '`)=0'; } else { $equal = '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value); } switch ($condField->getCondition()) { case '=': $allConditions .= $equal; break; case '<=': case '>=': $allConditions .= '(`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value) . ' OR ' . $equal . ') '; break; } } else { $allConditions .= '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value); } } } else { $allConditions .= '`' . $field_name . '` like ' . DB::escape("%{$value}"); } } else { $allConditions .= ' true'; } } } } if (count($conditionsCp) > 0) { $dateFormat = user_config_option('date_format'); $date_format_tip = date_format_tip($dateFormat); foreach ($conditionsCp as $condCp) { $cp = CustomProperties::getCustomProperty($condCp->getCustomPropertyId()); $skip_condition = false; if (isset($params[$condCp->getId() . "_" . $cp->getName()])) { $value = $params[$condCp->getId() . "_" . $cp->getName()]; } else { $value = $condCp->getValue(); } if ($value == '' && $condCp->getIsParametrizable()) { $skip_condition = true; } if (!$skip_condition) { $current_condition = ' AND '; $current_condition .= 'o.id IN ( SELECT object_id as id FROM ' . TABLE_PREFIX . 'custom_property_values cpv WHERE '; $current_condition .= ' cpv.custom_property_id = ' . $condCp->getCustomPropertyId(); $fieldType = $object->getColumnType($condCp->getFieldName()); if ($condCp->getCondition() == 'like' || $condCp->getCondition() == 'not like') { $value = '%' . $value . '%'; } if ($cp->getType() == 'date') { if ($value == $date_format_tip) { continue; } $dtValue = DateTimeValueLib::dateFromFormatAndString($dateFormat, $value); $value = $dtValue->format('Y-m-d H:i:s'); } if ($condCp->getCondition() != '%') { if ($cp->getType() == 'numeric') { $current_condition .= ' AND cpv.value ' . $condCp->getCondition() . ' ' . DB::escape($value); } else { if ($cp->getType() == 'boolean') { $current_condition .= ' AND cpv.value ' . $condCp->getCondition() . ' ' . ($value ? '1' : '0'); if (!$value) { $current_condition .= ') OR o.id NOT IN (SELECT object_id as id FROM ' . TABLE_PREFIX . 'custom_property_values cpv2 WHERE cpv2.object_id=o.id AND cpv2.value=1 AND cpv2.custom_property_id = ' . $condCp->getCustomPropertyId(); } } else { $current_condition .= ' AND cpv.value ' . $condCp->getCondition() . ' ' . DB::escape($value); } } } else { $current_condition .= ' AND cpv.value like ' . DB::escape("%{$value}"); } $current_condition .= ')'; $allConditions .= $current_condition; } } } $select_columns = array('*'); $join_params = null; if ($order_by_col == '') { $order_by_col = $report->getOrderBy(); } if ($ot->getHandlerClass() == 'Contacts' && in_array($order_by_col, $contact_extra_columns)) { $join_params = self::get_extra_contact_column_order_by($order_by_col, $order_by_col, $select_columns); } $original_order_by_col = $order_by_col; if (in_array($order_by_col, self::$external_columns)) { $order_by_col = 'name_order'; $join_params = array('table' => Objects::instance()->getTableName(), 'jt_field' => 'id', 'e_field' => $original_order_by_col, 'join_type' => 'left'); $select_columns = array(); $tmp_cols = $managerInstance->getColumns(); foreach ($tmp_cols as $col) { $select_columns[] = "e.{$col}"; } $tmp_cols = Objects::instance()->getColumns(); foreach ($tmp_cols as $col) { $select_columns[] = "o.{$col}"; } $select_columns[] = 'jt.name as name_order'; } if ($order_by_asc == null) { $order_by_asc = $report->getIsOrderByAsc(); } if ($ot->getName() == 'task' && !SystemPermissions::userHasSystemPermission(logged_user(), 'can_see_assigned_to_other_tasks')) { $allConditions .= " AND assigned_to_contact_id = " . logged_user()->getId(); } if ($managerInstance) { if ($order_by_col == "order") { $order_by_col = "`{$order_by_col}`"; } $listing_parameters = array("select_columns" => $select_columns, "order" => "{$order_by_col}", "order_dir" => $order_by_asc ? "ASC" : "DESC", "extra_conditions" => $allConditions, "count_results" => true, "join_params" => $join_params); if ($limit > 0) { $listing_parameters["start"] = $offset; $listing_parameters["limit"] = $limit; } if ($show_archived) { $listing_parameters["archived"] = true; } $result = $managerInstance->listing($listing_parameters); } else { // TODO Performance Killer $result = ContentDataObjects::getContentObjects(active_context(), $ot, $order_by_col, $order_by_asc ? "ASC" : "DESC", $allConditions); } $objects = $result->objects; $totalResults = $result->total; $results['pagination'] = Reports::getReportPagination($id, $params, $original_order_by_col, $order_by_asc, $offset, $limit, $totalResults); $dimensions_cache = array(); foreach ($report_columns as $column) { if ($column->getCustomPropertyId() == 0) { $field = $column->getFieldName(); if (str_starts_with($field, 'dim_')) { $dim_id = str_replace("dim_", "", $field); $dimension = Dimensions::getDimensionById($dim_id); $dimensions_cache[$dim_id] = $dimension; $column_name = $dimension->getName(); $results['columns'][$field] = $column_name; $results['db_columns'][$column_name] = $field; } else { if ($managerInstance->columnExists($field) || Objects::instance()->columnExists($field)) { $column_name = Localization::instance()->lang('field ' . $ot->getHandlerClass() . ' ' . $field); if (is_null($column_name)) { $column_name = lang('field Objects ' . $field); } $results['columns'][$field] = $column_name; $results['db_columns'][$column_name] = $field; } else { if ($ot->getHandlerClass() == 'Contacts') { if (in_array($field, $contact_extra_columns)) { $results['columns'][$field] = lang($field); $results['db_columns'][lang($field)] = $field; } } else { if ($ot->getHandlerClass() == 'Timeslots') { if (in_array($field, array('time', 'billing'))) { $results['columns'][$field] = lang('field Objects ' . $field); $results['db_columns'][lang('field Objects ' . $field)] = $field; } } else { if ($ot->getHandlerClass() == 'MailContents') { if (in_array($field, array('to', 'cc', 'bcc', 'body_plain', 'body_html'))) { $results['columns'][$field] = lang('field Objects ' . $field); $results['db_columns'][lang('field Objects ' . $field)] = $field; } } } } } } } else { $results['columns'][$column->getCustomPropertyId()] = $column->getCustomPropertyId(); } } $report_rows = array(); foreach ($objects as &$object) { /* @var $object Object */ $obj_name = $object->getObjectName(); $icon_class = $object->getIconClass(); $row_values = array('object_type_id' => $object->getObjectTypeId()); if (!$to_print) { $row_values['link'] = '<a class="link-ico ' . $icon_class . '" title="' . clean($obj_name) . '" target="new" href="' . $object->getViewUrl() . '"> </a>'; } foreach ($report_columns as $column) { if ($column->getCustomPropertyId() == 0) { $field = $column->getFieldName(); if (str_starts_with($field, 'dim_')) { $dim_id = str_replace("dim_", "", $field); if (!array_var($dimensions_cache, $dim_id) instanceof Dimension) { $dimension = Dimensions::getDimensionById($dim_id); $dimensions_cache[$dim_id] = $dimension; } else { $dimension = array_var($dimensions_cache, $dim_id); } $om_object_id = $object instanceof Timeslot ? $object->getRelObjectId() : $object->getId(); $members = ObjectMembers::getMembersByObjectAndDimension($om_object_id, $dim_id, " AND om.is_optimization=0"); $value = ""; foreach ($members as $member) { /* @var $member Member */ $val = $member->getPath(); $val .= ($val == "" ? "" : "/") . $member->getName(); if ($value != "") { $val = " - {$val}"; } $value .= $val; } $row_values[$field] = $value; } else { if ($object instanceof Timeslot) { if ($field == 'id') { $value = $object->getObjectId(); } else { $value = $object->getColumnValue($field); // if it is a task column if (in_array($field, ProjectTasks::instance()->getColumns())) { $task = ProjectTasks::findById($object->getRelObjectId()); // if task exists if ($task instanceof ProjectTask) { $value = $task->getColumnValue($field); // if it is an external task column if (in_array($field, ProjectTasks::instance()->getExternalColumns())) { $value = self::instance()->getExternalColumnValue($field, $value, ProjectTasks::instance()); } else { // if is a date then use format if (ProjectTasks::instance()->getColumnType($field) == DATA_TYPE_DATETIME && $value instanceof DateTimeValue) { $value = format_value_to_print($field, $value->toMySQL(), DATA_TYPE_DATETIME, $report->getReportObjectTypeId()); } } } $results['columns'][$field] = lang('field ProjectTasks ' . $field); $results['db_columns'][lang('field ProjectTasks ' . $field)] = $field; } } } else { $value = $object->getColumnValue($field); } if ($value instanceof DateTimeValue) { $dateFormat = user_config_option('date_format'); Hook::fire("custom_property_date_format", null, $dateFormat); $tz = logged_user()->getTimezone(); if ($object instanceof ProjectTask) { if ($field == 'due_date' && !$object->getUseDueTime() || $field == 'start_date' && !$object->getUseStartTime()) { $dateFormat = user_config_option('date_format'); $tz = 0; } } $value = format_date($value, $dateFormat, $tz * 3600); } if (in_array($field, $managerInstance->getExternalColumns())) { if ($object instanceof Timeslot && $field == 'time') { $lastStop = $object->getEndTime() != null ? $object->getEndTime() : ($object->isPaused() ? $object->getPausedOn() : DateTimeValueLib::now()); $seconds = $lastStop->getTimestamp() - $object->getStartTime()->getTimestamp(); $hours = number_format($seconds / 3600, 2, ',', '.'); $value = $hours; //$value = DateTimeValue::FormatTimeDiff($object->getStartTime(), $lastStop, "hm", 60, $object->getSubtract()); } else { if ($object instanceof Timeslot && $field == 'billing') { $value = config_option('currency_code', '$') . ' ' . $object->getFixedBilling(); } else { $value = self::instance()->getExternalColumnValue($field, $value, $managerInstance); } } } else { if ($field != 'link') { //$value = html_to_text(html_entity_decode($value)); if ($object->getColumnType($field) == DATA_TYPE_STRING) { // change html block end tags and brs to \n, then remove all other html tags, then replace \n with <br>, to remove all styles and keep the enters $value = str_replace(array("</div>", "</p>", "<br>", "<br />", "<br/>"), "\n", $value); $value = nl2br(strip_tags($value)); } } } if (self::isReportColumnEmail($value)) { if (logged_user()->hasMailAccounts()) { $value = '<a class="internalLink" href="' . get_url('mail', 'add_mail', array('to' => clean($value))) . '">' . clean($value) . '</a></div>'; } else { $value = '<a class="internalLink" target="_self" href="mailto:' . clean($value) . '">' . clean($value) . '</a></div>'; } } $row_values[$field] = $value; if ($ot->getHandlerClass() == 'Contacts') { if ($managerInstance instanceof Contacts) { $contact = Contacts::findOne(array("conditions" => "object_id = " . $object->getId())); if ($field == "email_address") { $row_values[$field] = $contact->getEmailAddress(); } if ($field == "is_user") { $row_values[$field] = $contact->getUserType() > 0 && !$contact->getIsCompany(); } if ($field == "im_values") { $str = ""; foreach ($contact->getAllImValues() as $type => $value) { $str .= ($str == "" ? "" : " | ") . "{$type}: {$value}"; } $row_values[$field] = $str; } if (in_array($field, array("mobile_phone", "work_phone", "home_phone"))) { if ($field == "mobile_phone") { $row_values[$field] = $contact->getPhoneNumber('mobile', null, false); } else { if ($field == "work_phone") { $row_values[$field] = $contact->getPhoneNumber('work', null, false); } else { if ($field == "home_phone") { $row_values[$field] = $contact->getPhoneNumber('home', null, false); } } } } if (in_array($field, array("personal_webpage", "work_webpage", "other_webpage"))) { if ($field == "personal_webpage") { $row_values[$field] = $contact->getWebpageUrl('personal'); } else { if ($field == "work_webpage") { $row_values[$field] = $contact->getWebpageUrl('work'); } else { if ($field == "other_webpage") { $row_values[$field] = $contact->getWebpageUrl('other'); } } } } if (in_array($field, array("home_address", "work_address", "other_address"))) { if ($field == "home_address") { $row_values[$field] = $contact->getStringAddress('home'); } else { if ($field == "work_address") { $row_values[$field] = $contact->getStringAddress('work'); } else { if ($field == "other_address") { $row_values[$field] = $contact->getStringAddress('other'); } } } } } } else { if ($ot->getHandlerClass() == 'MailContents') { if (in_array($field, array('to', 'cc', 'bcc', 'body_plain', 'body_html'))) { $mail_data = MailDatas::findById($object->getId()); $row_values[$field] = $mail_data->getColumnValue($field); if ($field == "body_html") { if (class_exists("DOMDocument")) { $d = new DOMDocument(); $mock = new DOMDocument(); $d->loadHTML(remove_css_and_scripts($row_values[$field])); $body = $d->getElementsByTagName('body')->item(0); foreach ($body->childNodes as $child) { $mock->appendChild($mock->importNode($child, true)); } // if css is inside an html comment => remove it $row_values[$field] = preg_replace('/<!--(.*)-->/Uis', '', remove_css($row_values[$field])); } else { $row_values[$field] = preg_replace('/<!--(.*)-->/Uis', '', remove_css_and_scripts($row_values[$field])); } } } } } if (!$to_print && $field == "name") { $row_values[$field] = '<a target="new-' . $object->getId() . '" href="' . $object->getViewUrl() . '">' . $value . '</a>'; } } } else { $colCp = $column->getCustomPropertyId(); $cp = CustomProperties::getCustomProperty($colCp); if ($cp instanceof CustomProperty) { /* @var $cp CustomProperty */ $row_values[$cp->getName()] = get_custom_property_value_for_listing($cp, $object); $results['columns'][$colCp] = $cp->getName(); $results['db_columns'][$cp->getName()] = $colCp; } } } Hook::fire("report_row", $object, $row_values); $report_rows[] = $row_values; } if (!$to_print) { if (is_array($results['columns'])) { array_unshift($results['columns'], ''); } else { $results['columns'] = array(''); } Hook::fire("report_header", $ot, $results['columns']); } $results['rows'] = $report_rows; } return $results; }
<?php $user = User::model()->findByPk($model['uploaded_by']); $org = Objects::model()->findByPk($model['org']); $url = Yii::app()->createAbsoluteUrl('/fastreview/item', array( 'id'=>$org->id, 'dash'=>'-', 'itemurl'=>$org->url)); if(!empty($user)){ $user_avatar = $user->getAvatar(); $user_name = $user->fullname; } else { $user_avatar = '/img/avatar.png'; $user_name = 'Аноним'; } ?> <div class="oblects_view"> <div class="media"> <div class="pull-left"> <div class="iAvatar"> <img class="lv-img-lg" src="<?php echo $user_avatar; ?>" alt=""> </div> </div> <div class="media-body"> <div class="iAuthor"> <span style="color:#333;font-size:17px;font-weight:300;display:block;line-height:1.3em;"><?php echo $user_name; ?></span> <span class="c-gray f-11" style="display:block;"><?php echo Yii::app()->dateFormatter->format('d MMMM yyyy', $model['date']); ?></span> </div> <span style="font-weight:bold;"><?php echo CHtml::link($org->title,$url,array('class'=>'nocolor')); ?></span> <div class="lightbox row lastimages">
<?php chdir(dirname(__FILE__)); header("Content-type: text/plain"); define("CONSOLE_MODE", true); include "init.php"; Env::useHelper('format'); define('SCRIPT_MEMORY_LIMIT', 1024 * 1024 * 1024); // 1 GB @set_time_limit(0); ini_set('memory_limit', SCRIPT_MEMORY_LIMIT / (1024 * 1024) + 50 . 'M'); $i = 0; $objects_ids = Objects::instance()->findAll(array('columns' => array('id'), 'id' => true)); //,'conditions' => 'object_type_id = 6' echo "\nObjects to process: " . count($objects_ids) . "\n-----------------------------------------------------------------"; foreach ($objects_ids as $object_id) { $object = Objects::findObject($object_id); $i++; if ($object instanceof ContentDataObject) { $members = $object->getMembers(); DB::execute("DELETE FROM " . TABLE_PREFIX . "object_members WHERE object_id = " . $object->getId() . " AND is_optimization = 1;"); ObjectMembers::addObjectToMembers($object->getId(), $members); } else { // } if ($i % 100 == 0) { echo "\n{$i} objects processed. Mem usage: " . format_filesize(memory_get_usage(true)); } }
/** * Indicates whether the argument on postion $pos machtes the specified * value. * * @param int pos * @param var value * @return bool */ private function doesMatchArg($pos, $value) { $argVal = $this->args[$pos]; if ($argVal instanceof IArgumentMatcher) { return $argVal->matches($value); } else { return Objects::equal($argVal, $value); } }
function repetitive_tasks_related($task, $action, $type_related = "", $task_data = array()) { //I find all those related to the task to find out if the original $task_related = ProjectTasks::findByRelated($task->getObjectId()); if (!$task_related) { //is not the original as the original look plus other related if ($task->getOriginalTaskId() != "0") { $task_related = ProjectTasks::findByTaskAndRelated($task->getObjectId(), $task->getOriginalTaskId()); } } if ($task_related) { switch ($action) { case "edit": foreach ($task_related as $t_rel) { if ($type_related == "news") { if ($task->getStartDate() <= $t_rel->getStartDate() && $task->getDueDate() <= $t_rel->getDueDate()) { $this->repetitive_task_related_edit($t_rel, $task_data); } } else { $this->repetitive_task_related_edit($t_rel, $task_data); } } break; case "delete": $delete_task = array(); foreach ($task_related as $t_rel) { $task_rel = Objects::findObject($t_rel->getId()); if ($type_related == "news") { if ($task->getStartDate() <= $t_rel->getStartDate() && $task->getDueDate() <= $t_rel->getDueDate()) { $delete_task[] = $t_rel->getId(); $task_rel->trash(); } } else { $delete_task[] = $t_rel->getId(); $task_rel->trash(); } } return $delete_task; break; case "archive": $archive_task = array(); foreach ($task_related as $t_rel) { $task_rel = Objects::findObject($t_rel->getId()); if ($type_related == "news") { if ($task->getStartDate() <= $t_rel->getStartDate() && $task->getDueDate() <= $t_rel->getDueDate()) { $archive_task[] = $t_rel->getId(); $t_rel->archive(); } } else { $archive_task[] = $t_rel->getId(); $t_rel->archive(); } } return $archive_task; break; } } }