コード例 #1
0
 private function list_members($request)
 {
     $service = $request['srv'];
     $members = array();
     $type = ObjectTypes::instance()->findByName($service);
     $typeId = $type->getId();
     $ids = array();
     $dimensionController = new DimensionController();
     foreach ($dimensionController->initial_list_dimension_members(Dimensions::findByCode('customer_project')->getId(), $typeId) as $member) {
         $ids[] = $member['object_id'];
     }
     if (count($ids)) {
         $args['conditions'] = " `object_id` IN (" . implode(",", $ids) . ") AND object_type_id = {$typeId}";
         foreach (Members::instance()->findAll($args) as $member) {
             /* @var $member Member */
             $memberInfo = array('id' => $member->getId(), 'name' => $member->getName(), 'type' => $service, 'path' => $member->getPath());
             $members[] = $memberInfo;
         }
     }
     return $this->response('json', $members);
 }
コード例 #2
0
 function quick_add_form()
 {
     $this->setLayout('empty');
     if ($dimension_id = array_var($_GET, 'dimension_id')) {
         $dimension = Dimensions::instance()->findById($dimension_id);
         $dimensionOptions = $dimension->getOptions(true);
         $object_Types = array();
         $parent_member_id = array_var($_GET, 'parent_member_id');
         if ($parent_member_id) {
             $parent_member = Members::instance()->findById($parent_member_id);
             $object_types = DimensionObjectTypes::getChildObjectTypes($parent_member_id);
         } else {
             $object_types = DimensionObjectTypes::instance()->findAll(array("conditions" => "dimension_id = {$dimension_id} AND is_root = 1 "));
         }
         if (count($object_types)) {
             if (count($object_types) == 1) {
                 // Input Hidden
                 tpl_assign('object_type', $object_types[0]);
                 tpl_assign('object_type_name', ObjectTypes::instance()->findById($object_types[0]->getObjectTypeId())->getName());
             } else {
                 // Input combo
                 tpl_assign('object_types', $object_types);
             }
         } else {
             tpl_assign("error_msg", $parent_member->getName() . " does not accept child nodes ");
         }
         $editUrls = array();
         foreach ($object_types as $object_type) {
             /* @var $object_type DimensionObjectType */
             if (ObjectTypes::instance()->findById($object_type->getObjectTypeId())->getType() != 'dimension_object') {
                 continue;
             }
             $options = $object_type->getOptions(1);
             if (isset($options->defaultAjax) && $options->defaultAjax->controller != "dashboard") {
                 $editUrls[$object_type->getObjectTypeId()] = get_url($options->defaultAjax->controller, 'add');
             } else {
                 $t = ObjectTypes::instance()->findById($object_type->getObjectTypeId());
                 /* @var $t ObjectType */
                 $class_name = ucfirst($t->getName()) . "Controller";
                 if ($t && controller_exists($t->getName(), $t->getPluginId())) {
                     $editUrls[$object_type->getObjectTypeId()] = get_url($t->getName(), 'add');
                 } else {
                     $editUrls[$object_type->getObjectTypeId()] = get_url('member', 'add', array("dim_id" => $dimension_id));
                 }
             }
         }
         tpl_assign('editUrls', $editUrls);
         tpl_assign('parent_member_id', $parent_member_id);
         tpl_assign('dimension_id', $dimension_id);
         if (is_object($dimensionOptions) && is_object($dimensionOptions->quickAdd) && $dimensionOptions->quickAdd->formAction) {
             tpl_assign('form_action', ROOT_URL . "/" . $dimensionOptions->quickAdd->formAction);
         } else {
             tpl_assign('form_action', get_url('member', 'add', array('quick' => '1')));
         }
     } else {
         die("SORRY. Invalid dimension");
     }
 }
コード例 #3
0
 static function addObjToSharingTable($oid, $tid, $obj_mem_ids)
 {
     $gids = array();
     $table_prefix = defined('FORCED_TABLE_PREFIX') && FORCED_TABLE_PREFIX ? FORCED_TABLE_PREFIX : TABLE_PREFIX;
     //1. clear sharing table for this object
     SharingTables::delete("object_id={$oid}");
     //2. get dimensions of this object's members that defines permissions
     $res = DB::execute("SELECT d.id as did FROM " . $table_prefix . "dimensions d INNER JOIN " . $table_prefix . "members m on m.dimension_id=d.id\r\n\t\t\t\tWHERE m.id IN ( SELECT member_id FROM " . $table_prefix . "object_members WHERE object_id = {$oid} AND is_optimization = 0 ) AND d.defines_permissions = 1");
     $dids_tmp = array();
     while ($row = $res->fetchRow()) {
         $dids_tmp[$row['did']] = $row['did'];
     }
     $res->free();
     $dids = array_values($dids_tmp);
     $dids_tmp = null;
     $sql_from = "" . $table_prefix . "contact_member_permissions cmp\r\n\t\tLEFT JOIN " . $table_prefix . "members m ON m.id = cmp.member_id\r\n\t\tLEFT JOIN " . $table_prefix . "dimensions d ON d.id = m.dimension_id";
     $member_where_conditions = "";
     $dim_where_conditions = "";
     // if users can add objects without classifying then check for permissions with member_id=0
     if (config_option('let_users_create_objects_in_root')) {
         $member_where_conditions = "member_id=0 OR ";
         $dim_where_conditions = " OR d.id IS NULL";
     }
     $sql_where = "({$member_where_conditions} member_id IN ( SELECT member_id FROM " . $table_prefix . "object_members WHERE object_id = {$oid} AND is_optimization = 0)) AND cmp.object_type_id = {$tid}";
     //3. If there are dimensions that defines permissions containing any of the object members
     if (count($dids)) {
         // 3.1 get permission groups with permissions over the object.
         $sql_fields = "permission_group_id  AS group_id";
         $sql = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t{$sql_fields}\r\n\t\t\t\tFROM\r\n\t\t\t\t{$sql_from}\r\n\t\t\t\tWHERE\r\n\t\t\t\t{$sql_where} AND (d.id IN (" . implode(',', $dids) . ") {$dim_where_conditions})\r\n\t\t\t";
         $res = DB::execute($sql);
         $gids_tmp = array();
         while ($row = $res->fetchRow()) {
             $gids_tmp[$row['group_id']] = $row['group_id'];
         }
         $res->free();
         // allow all permission groups
         $allow_all_rows = DB::executeAll("SELECT DISTINCT permission_group_id FROM " . $table_prefix . "contact_dimension_permissions cdp\r\n\t\t\t\t\tINNER JOIN " . $table_prefix . "members m on m.dimension_id=cdp.dimension_id\r\n\t\t\t\t\tWHERE cdp.permission_type='allow all' AND cdp.dimension_id IN (" . implode(',', $dids) . ");");
         if (is_array($allow_all_rows)) {
             foreach ($allow_all_rows as $row) {
                 $gids_tmp[$row['permission_group_id']] = $row['permission_group_id'];
             }
         }
         $gids = array_values($gids_tmp);
         $gids_tmp = null;
         // check for mandatory dimensions
         $enabled_dimensions_sql = "";
         $enabled_dimensions_ids = implode(',', config_option('enabled_dimensions'));
         if ($enabled_dimensions_ids != "") {
             $enabled_dimensions_sql = "AND id IN ({$enabled_dimensions_ids})";
         }
         $mandatory_dim_ids = Dimensions::findAll(array('id' => true, 'conditions' => "`defines_permissions`=1 {$enabled_dimensions_sql} AND `permission_query_method`='" . DIMENSION_PERMISSION_QUERY_METHOD_MANDATORY . "'"));
         if (count($gids) > 0 && count($mandatory_dim_ids) > 0) {
             $sql = "SELECT om.member_id, m.dimension_id FROM " . $table_prefix . "object_members om\r\n\t\t\t\t\tINNER JOIN " . $table_prefix . "members m ON m.id=om.member_id INNER JOIN " . $table_prefix . "dimensions d ON d.id=m.dimension_id\r\n\t\t\t\t\tWHERE om.object_id = {$oid} AND om.is_optimization = 0 AND d.id IN (" . implode(",", $mandatory_dim_ids) . ")";
             // Object members in mandatory dimensions
             $object_member_ids_res = DB::executeAll($sql);
             $mandatory_dim_members = array();
             if (!is_null($object_member_ids_res)) {
                 foreach ($object_member_ids_res as $row) {
                     if (!isset($mandatory_dim_members[$row['dimension_id']])) {
                         $mandatory_dim_members[$row['dimension_id']] = array();
                     }
                     $mandatory_dim_members[$row['dimension_id']][] = $row['member_id'];
                 }
                 $mandatory_dim_allowed_pgs = array();
                 // Check foreach group that it has permissions over at least one member of each mandatory dimension
                 foreach ($mandatory_dim_members as $mdim_id => $mmember_ids) {
                     $sql = "SELECT pg.id FROM " . $table_prefix . "permission_groups pg\r\n\t\t\t\t\t\t\tINNER JOIN " . $table_prefix . "contact_dimension_permissions cdp ON cdp.permission_group_id=pg.id\r\n\t\t\t\t\t\t\tINNER JOIN " . $table_prefix . "contact_member_permissions cmp ON cmp.permission_group_id=pg.id\r\n\t\t\t\t\t\t\tWHERE cdp.dimension_id = '{$mdim_id}' AND (\r\n\t\t\t\t\t\t\tcdp.permission_type='allow all' OR cdp.permission_type='check' AND cmp.permission_group_id IN (" . implode(',', $gids) . ")\r\n\t\t\t\t\t\t\tAND cmp.member_id IN (" . implode(',', $mmember_ids) . ")\r\n\t\t\t\t\t\t)";
                     $permission_groups_res = DB::executeAll($sql);
                     $mandatory_dim_allowed_pgs[$mdim_id] = array();
                     if (!is_null($permission_groups_res)) {
                         foreach ($permission_groups_res as $row) {
                             if (!in_array($row['id'], $mandatory_dim_allowed_pgs[$mdim_id])) {
                                 $mandatory_dim_allowed_pgs[$mdim_id][] = $row['id'];
                             }
                         }
                     }
                 }
                 if (isset($mandatory_dim_allowed_pgs) && count($mandatory_dim_allowed_pgs) > 0) {
                     $original_mandatory_dim_allowed_pgs = $mandatory_dim_allowed_pgs;
                     $allowed_gids = array_pop($mandatory_dim_allowed_pgs);
                     foreach ($mandatory_dim_allowed_pgs as $pg_array) {
                         $allowed_gids = array_intersect($allowed_gids, $pg_array);
                     }
                     // If an user has permissions in one dim using a group and in other dim using his personal permissions then add to sharing table its personal permission group
                     $pg_ids = array_unique(array_flat($original_mandatory_dim_allowed_pgs));
                     if (count($pg_ids) == 0) {
                         $pg_ids[0] = 0;
                     }
                     $contact_pgs = array();
                     $contact_pg_rows = DB::executeAll("SELECT * FROM " . TABLE_PREFIX . "contact_permission_groups WHERE permission_group_id IN (" . implode(',', $pg_ids) . ") ORDER BY permission_group_id");
                     if (is_array($contact_pg_rows)) {
                         foreach ($contact_pg_rows as $cpgr) {
                             if (!isset($contact_pgs[$cpgr['contact_id']])) {
                                 $contact_pgs[$cpgr['contact_id']] = array();
                             }
                             $contact_pgs[$cpgr['contact_id']][] = $cpgr['permission_group_id'];
                         }
                     }
                     // each user must have at least one pg for every dimension
                     foreach ($contact_pgs as $contact_id => $permission_groups) {
                         $has_one = array_flip(array_keys($original_mandatory_dim_allowed_pgs));
                         foreach ($has_one as $k => &$v) {
                             $v = false;
                         }
                         foreach ($permission_groups as $pg_id) {
                             foreach ($original_mandatory_dim_allowed_pgs as $dim_id => $allowedpgs) {
                                 if (in_array($pg_id, $allowedpgs)) {
                                     $has_one[$dim_id] = true;
                                     break;
                                 }
                             }
                         }
                         // all dims must be true in this array to allow permissions
                         $has_permission = !in_array(false, $has_one);
                         if ($has_permission) {
                             $contact_row = DB::executeOne("SELECT permission_group_id FROM " . TABLE_PREFIX . "contacts where object_id = {$contact_id}");
                             if (is_array($contact_row) && $contact_row['permission_group_id'] > 0) {
                                 $allowed_gids[] = $contact_row['permission_group_id'];
                             }
                         }
                     }
                     $gids = array_unique($allowed_gids, SORT_NUMERIC);
                 } else {
                     $gids = array();
                 }
             }
         }
     } else {
         if ($obj_mem_ids) {
             // 3.2 No memeber dimensions defines permissions.
             // No esta en ninguna dimension que defina permisos, El objecto esta en algun lado
             // => En todas las dimensiones en la que está no definen permisos => Busco todos los grupos
             $gids = PermissionGroups::instance()->findAll(array('id' => true, 'conditions' => "type != 'roles'"));
         } else {
             // if this object is an email and it is unclassified => add to sharing table the permission groups of the users that have permissions in the email's account
             if (Plugins::instance()->isActivePlugin('mail')) {
                 $mail_ot = ObjectTypes::instance()->findByName('mail');
                 if ($mail_ot instanceof ObjectType && $tid == $mail_ot->getId()) {
                     $gids = array_flat(DB::executeAll("\r\n\t\t\t\t\t\t\tSELECT cpg.permission_group_id\r\n\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "contact_permission_groups cpg\r\n\t\t\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "contacts c ON c.permission_group_id=cpg.permission_group_id\r\n\t\t\t\t\t\t\tWHERE cpg.contact_id IN (\r\n\t\t\t\t\t\t\t  SELECT mac.contact_id FROM " . TABLE_PREFIX . "mail_account_contacts mac WHERE mac.account_id = (SELECT mc.account_id FROM " . TABLE_PREFIX . "mail_contents mc WHERE mc.object_id={$oid})\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t"));
                 }
             }
         }
     }
     if (count($gids)) {
         $stManager = SharingTables::instance();
         $stManager->populateGroups($gids, $oid);
         $gids = null;
     }
 }
コード例 #4
0
 function quick_add_form()
 {
     ajx_current("empty");
     $this->setLayout('empty');
     $dimension_id = array_var($_GET, 'dimension_id');
     $dimension = is_numeric($dimension_id) ? Dimensions::instance()->findById($dimension_id) : null;
     if ($dimension instanceof Dimension) {
         $object_Types = array();
         $parent_member_id = array_var($_GET, 'parent_member_id');
         $parent_member = Members::instance()->findById($parent_member_id);
         if ($parent_member instanceof Member) {
             $object_types = DimensionObjectTypes::getChildObjectTypes($parent_member);
             if (count($object_types) == 0) {
                 $parent_member = null;
                 $object_types = DimensionObjectTypes::instance()->findAll(array("conditions" => "enabled=1 AND dimension_id = {$dimension_id} AND is_root = 1 AND object_type_id<>(SELECT id from " . TABLE_PREFIX . "object_types WHERE name='company')"));
             }
         } else {
             $object_types = DimensionObjectTypes::instance()->findAll(array("conditions" => "enabled=1 AND dimension_id = {$dimension_id} AND is_root = 1 AND object_type_id<>(SELECT id from " . TABLE_PREFIX . "object_types WHERE name='company')"));
         }
         $obj_types = array();
         $editUrls = array();
         foreach ($object_types as $object_type) {
             $options = $object_type->getOptions(1);
             if (isset($options->defaultAjax) && $options->defaultAjax->controller != "dashboard") {
                 $editUrls[$object_type->getObjectTypeId()] = get_url($options->defaultAjax->controller, 'add');
             } else {
                 $t = ObjectTypes::instance()->findById($object_type->getObjectTypeId());
                 $obj_types[$t->getId()] = $t;
                 $class_name = ucfirst($t->getName()) . "Controller";
                 $controller_exists = controller_exists($t->getName(), $t->getPluginId());
                 if ($controller_exists) {
                     Env::useController(ucfirst($t->getName()));
                     eval('$controller = new ' . $class_name . '();');
                 }
                 if ($t && controller_exists($t->getName(), $t->getPluginId()) && $t->getHandlerClass() != '' && $controller_exists && method_exists($controller, 'add')) {
                     $params = array("type" => $t->getId());
                     if ($parent_member instanceof Member) {
                         $params['parent'] = $parent_member->getId();
                     }
                     $editUrls[$t->getId()] = get_url($t->getName(), 'add', $params);
                 } else {
                     $params = array("dim_id" => $dimension_id, "type" => $t->getId());
                     if ($parent_member instanceof Member) {
                         $params['parent'] = $parent_member->getId();
                     }
                     $editUrls[$t->getId()] = get_url('member', 'add', $params);
                 }
             }
         }
         $urls = array();
         foreach ($editUrls as $ot_id => $url) {
             $ot = array_var($obj_types, $ot_id);
             if ($ot instanceof ObjectType) {
                 $link_text = ucfirst(strtolower(lang('new ' . $ot->getName())));
                 $iconcls = $ot->getIconClass();
             } else {
                 $link_text = lang('new');
                 $iconcls = "";
             }
             $urls[] = array('link_text' => $link_text, 'url' => $url, 'iconcls' => $iconcls);
         }
         Hook::fire('member_quick_add_urls', array('dimension' => $dimension, 'object_types' => $object_types, 'parent_member' => $parent_member), $urls);
         if (count($urls) > 1) {
             ajx_extra_data(array('draw_menu' => 1, 'urls' => $urls));
         } else {
             ajx_extra_data(array('urls' => $urls));
         }
     } else {
         Logger::log("Invalid dimension: {$dimension_id}");
     }
 }
コード例 #5
0
 /**
  * List custom properties
  *
  * @access public
  * @param void
  * @return null
  */
 function custom_properties()
 {
     if (!can_manage_configuration(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $object_types = ObjectTypes::instance()->findAll(array("conditions" => "`type` IN ('content_object')  AND `name` <> 'template_task' AND name <> 'template_milestone' AND `name` <> 'file revision'", "order" => "name"));
     $ordered_object_types = array();
     foreach ($object_types as $ot) {
         $ordered_object_types[$ot->getId()] = lang($ot->getName());
     }
     asort($ordered_object_types, SORT_STRING);
     $select_options = array('<option value="" selected>' . lang('select one') . '</option>');
     foreach ($ordered_object_types as $k => $v) {
         $select_options[] = '<option value="' . $k . '">' . $v . '</option>';
     }
     tpl_assign('object_types', $select_options);
     $custom_properties = array_var($_POST, 'custom_properties');
     $obj_type_id = array_var($_POST, 'objectType');
     $delete = 0;
     if (is_array($custom_properties)) {
         try {
             DB::beginWork();
             foreach ($custom_properties as $id => $data) {
                 $new_cp = null;
                 if ($data['id'] != '') {
                     $new_cp = CustomProperties::getCustomProperty($data['id']);
                 }
                 if ($new_cp == null) {
                     $new_cp = new CustomProperty();
                 }
                 if ($data['deleted'] == "1") {
                     $delete = $delete + 1;
                     if (!$new_cp->isNew()) {
                         $new_cp->delete();
                     }
                     continue;
                 }
                 $new_cp->setObjectTypeId($obj_type_id);
                 $new_cp->setName($data['name']);
                 $new_cp->setType($data['type']);
                 $new_cp->setDescription($data['description']);
                 if ($data['type'] == 'list') {
                     $values = array();
                     $list = explode(",", $data['values']);
                     foreach ($list as $l) {
                         $values[] = trim($l);
                     }
                     $value = implode(",", $values);
                     $new_cp->setValues($value);
                 } else {
                     $new_cp->setValues($data['values']);
                 }
                 if ($data['type'] == 'boolean') {
                     $new_cp->setDefaultValue(isset($data['default_value_boolean']));
                 } else {
                     $new_cp->setDefaultValue($data['default_value']);
                 }
                 $new_cp->setIsRequired(isset($data['required']));
                 $new_cp->setIsMultipleValues(isset($data['multiple_values']));
                 $new_cp->setOrder($data['order'] - $delete);
                 $new_cp->setVisibleByDefault(isset($data['visible_by_default']));
                 $new_cp->save();
                 if (is_array(array_var($data, 'applyto'))) {
                     $applyto = array_var($data, 'applyto');
                     foreach ($applyto as $co_type => $value) {
                         if ($value == 'true') {
                             if (!CustomPropertiesByCoType::findById(array('co_type_id' => $co_type, 'cp_id' => $new_cp->getId()))) {
                                 $obj = new CustomPropertyByCoType();
                                 $obj->setCoTypeId($co_type);
                                 $obj->setCpId($new_cp->getId());
                                 $obj->save();
                             }
                         } else {
                             $obj = CustomPropertiesByCoType::findById(array('co_type_id' => $co_type, 'cp_id' => $new_cp->getId()));
                             if ($obj) {
                                 $obj->delete();
                             }
                         }
                     }
                 }
             }
             DB::commit();
             flash_success(lang('custom properties updated'));
             ajx_current('back');
         } catch (Exception $ex) {
             DB::rollback();
             flash_error($ex->getMessage());
         }
     }
 }
コード例 #6
0
 /**
  * Return manager instance
  *
  * @access protected
  * @param void
  * @return ObjectTypes 
  */
 function manager()
 {
     if (!$this->manager instanceof ObjectTypes) {
         $this->manager = ObjectTypes::instance();
     }
     return $this->manager;
 }
コード例 #7
0
 private function list_latest_active_members($request)
 {
     $service = $request['srv'];
     $members = array();
     $type = ObjectTypes::instance()->findByName($service);
     $typeId = $type->getId();
     if ($service == "workspace") {
         $dimension_id = Dimensions::findByCode('workspaces')->getId();
     } else {
         $dimension_id = Dimensions::findByCode('customer_project')->getId();
     }
     $ids = array();
     $dimensionController = new DimensionController();
     foreach ($dimensionController->latest_active_dimension_members($dimension_id, $typeId, null, user_config_option("mobile_logs_amount_to_search"), user_config_option("mobile_minimum_display_dimension_members"), user_config_option("mobile_maximum_display_dimension_members")) as $member) {
         $ids[] = $member['object_id'];
     }
     if (count($ids)) {
         $args['conditions'] = " `object_id` IN (" . implode(",", $ids) . ") AND object_type_id = {$typeId}";
         $args['order'] = " name ASC";
         foreach (Members::instance()->findAll($args) as $member) {
             /* @var $member Member */
             $memberInfo = array('id' => $member->getId(), 'name' => $member->getName(), 'type' => $service, 'path' => $member->getPath());
             $members[] = $memberInfo;
         }
     }
     return $this->response('json', $members);
 }
コード例 #8
0
ファイル: Dimension.class.php プロジェクト: rorteg/fengoffice
 function getAllowedObjectTypeContents()
 {
     return DimensionObjectTypeContents::findAll(array('conditions' => array("`dimension_id` = ?\n\t\t\tAND (`content_object_type_id` IN (SELECT `id` FROM " . ObjectTypes::instance()->getTableName(true) . " WHERE `type` = 'located')\n\t\t\tOR ( \n\t\t\t\t`content_object_type_id` NOT IN (SELECT `object_type_id` FROM " . TabPanels::instance()->getTableName(true) . " WHERE `enabled` = 0) \n\t  \t\t\tAND `content_object_type_id` IN (\n\t  \t\t\t\tSELECT `id` FROM " . ObjectTypes::instance()->getTableName(true) . " WHERE `type` = 'content_object' AND `name` <> 'file revision'\n\t  \t\t\t\t\tAND IF(plugin_id is NULL OR plugin_id = 0, TRUE, plugin_id IN (SELECT id FROM " . TABLE_PREFIX . "plugins WHERE is_activated > 0 AND is_installed > 0))\n\t  \t\t\t)\n  \t\t\t))", $this->getId()), 'distinct' => true));
 }
コード例 #9
0
 /**
 * Return manager instance
 *
 * @access protected
 * @param void
 * @return ObjectTypes 
 */
 function manager() {
   if(!($this->manager instanceof ObjectTypes)) $this->manager = ObjectTypes::instance();
   return $this->manager;
 } // manager
コード例 #10
0
	function getObjectType() {
		return ObjectTypes::instance()->findById($this->getObjectTypeId());
	}
コード例 #11
0
 /**
  * This function will return paginated result. Result is an array where first element is 
  * array of returned object and second populated pagination object that can be used for 
  * obtaining and rendering pagination data using various helpers.
  * 
  * Items and pagination array vars are indexed with 0 for items and 1 for pagination
  * because you can't use associative indexing with list() construct
  *
  * @access public
  * @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
  * @param integer $items_per_page Number of items per page
  * @param integer $current_page Current page number
  * @return array
  */
 function paginate($arguments = null, $items_per_page = 10, $current_page = 1)
 {
     if (isset($this) && instance_of($this, 'ObjectTypes')) {
         return parent::paginate($arguments, $items_per_page, $current_page);
     } else {
         return ObjectTypes::instance()->paginate($arguments, $items_per_page, $current_page);
     }
     // if
 }
コード例 #12
0
ファイル: index.php プロジェクト: abhinay100/fengoffice_app
<?php

$genid = gen_id();
$typeId = ObjectTypes::instance()->findByName("workspace")->getId();
//Check if There is a workspace in the active context
/* @var $member Member */
foreach (active_context_members(false) as $memberId) {
    $member = Members::instance()->findById($memberId);
    if ($member->getObjectTypeId() == $typeId) {
        $id = $member->getObjectId();
        if ($workspace = Workspaces::instance()->findById($id) && trim($member->getDescription()) != "") {
            $description = $member->getDescription();
            include_once 'template.php';
            break;
        }
    }
}
コード例 #13
0
ファイル: Member.class.php プロジェクト: rorteg/fengoffice
 /**
  * @author Ignacio Vazquez - elpepe.uy@gmail.com
  */
 function getIconClass()
 {
     if (!$this->icon_class) {
         if ($itemClass = $this->getObjectClass()) {
             eval("\$o = new {$itemClass}();");
             if ($o instanceof DimensionObject) {
                 $o->setId($this->getObjectId());
                 $o->setObjectId($this->getObjectId());
                 if ($icon_cls = $o->getIconClass()) {
                     $this->icon_class = $icon_cls;
                     return $this->icon_class;
                 }
             }
         }
         // If Obj instance do not define icon class, return object type definition
         $type = ObjectTypes::instance()->findById($this->getObjectTypeId());
         $this->icon_class = $type->getIconClass();
     }
     return $this->icon_class;
 }
コード例 #14
0
ファイル: edit_contact.php プロジェクト: abhinay100/feng_app
    ?>
	<div class="permissions-container form-tab" id="<?php 
    echo $genid;
    ?>
permissions" style="display:none;">
	<?php 
    if ($contact->isNew()) {
        $pg_id = $user_type;
        tpl_assign('is_new_user', true);
        $user = new Contact();
        $user->setUserType($user_type);
        tpl_assign('user', $user);
        // root permissions for new user
        $root_permissions = array();
        if (config_option('let_users_create_objects_in_root') && ($user->isAdminGroup() || $user->isExecutive() || $user->isManager())) {
            $all_object_types = ObjectTypes::instance()->findAll(array('conditions' => "type IN ('content_object', 'located') AND type NOT IN ('comment') AND name <> 'file revision' AND name <> 'template_task' AND name <> 'template_milestone' AND `name` <> 'template' AND\r\n\t\t\t\t\t(plugin_id IS NULL OR plugin_id = 0 OR plugin_id IN (SELECT id FROM " . TABLE_PREFIX . "plugins WHERE is_activated > 0 AND is_installed > 0))"));
            foreach ($all_object_types as $ot) {
                $root_permissions[$ot->getId()] = array('w' => 1, 'd' => 1, 'r' => 1);
            }
        }
        // Set role permissions for active members
        $sel_members = array();
        $member_permissions = array();
        $allowed_user_type_ids = config_option('give_member_permissions_to_new_users');
        $role_ot_permissions = RoleObjectTypePermissions::findAll(array('conditions' => "role_id = '{$user_type}' AND object_type_id NOT IN (SELECT id FROM " . TABLE_PREFIX . "object_types WHERE name IN ('template','comment'))"));
        $members_with_permissions = array();
        if (in_array($user_type, $allowed_user_type_ids)) {
            $enabled_dimension_ids = config_option('enabled_dimensions');
            if (count($enabled_dimension_ids) > 0) {
                $dimension_ids = Dimensions::findAll(array('id' => true, 'conditions' => "id in (" . implode(',', $enabled_dimension_ids) . ") AND defines_permissions=1 AND is_manageable=1"));
                if (count($dimension_ids) > 0) {
コード例 #15
0
	function findById($id, $force_reload = false) {
		if(isset($this) && instance_of($this, 'ObjectTypes')) {
			$ot = array_var(self::$object_types_by_id, $id);
			if (!$ot instanceof ObjectType) {
				// cache all object types, they are very few
				$ots = self::findAll();
				foreach ($ots as $ot) {
					self::$object_types_by_id[$ot->getId()] = $ot;
				}
				$ot = array_var(self::$object_types_by_id, $id);
			}
			return $ot;
		} else {
			return ObjectTypes::instance()->findById($id, $force_reload);
		}
	}
コード例 #16
0
 private function get_allowed_columns_custom_properties($object_type, $include_common_cols = true)
 {
     //return array(); //FIXME: no usar todo lo de custom properties por el momento
     $fields = array();
     if (isset($object_type)) {
         if (!is_numeric($object_type)) {
             $otype = ObjectTypes::instance()->findOne(array('conditions' => array('handler_class=?', $object_type)));
             if ($otype instanceof ObjectType) {
                 $object_type = $otype->getId();
             }
         }
         $customProperties = CustomProperties::getAllCustomPropertiesByObjectType($object_type);
         $objectFields = array();
         foreach ($customProperties as $cp) {
             if ($cp->getType() != 'table') {
                 $fields[] = array('id' => $cp->getId(), 'name' => $cp->getName(), 'type' => $cp->getType(), 'values' => $cp->getValues(), 'multiple' => $cp->getIsMultipleValues());
             }
         }
         $ot = ObjectTypes::findById($object_type);
         if (class_exists($ot->getHandlerClass())) {
             eval('$managerInstance = ' . $ot->getHandlerClass() . "::instance();");
             if ($include_common_cols) {
                 $common_columns = Objects::instance()->getColumns(false);
                 $common_columns = array_diff_key($common_columns, array_flip($managerInstance->getSystemColumns()));
                 $objectFields = array_merge($objectFields, $common_columns);
             }
         }
         foreach ($objectFields as $name => $type) {
             if ($type == DATA_TYPE_FLOAT || $type == DATA_TYPE_INTEGER) {
                 $type = 'numeric';
             } else {
                 if ($type == DATA_TYPE_STRING) {
                     $type = 'text';
                 } else {
                     if ($type == DATA_TYPE_BOOLEAN) {
                         $type = 'boolean';
                     } else {
                         if ($type == DATA_TYPE_DATE || $type == DATA_TYPE_DATETIME) {
                             $type = 'date';
                         }
                     }
                 }
             }
             $field_name = Localization::instance()->lang('field ' . $ot->getHandlerClass() . ' ' . $name);
             if (is_null($field_name)) {
                 $field_name = lang('field Objects ' . $name);
             }
             $fields[] = array('id' => $name, 'name' => $field_name, 'type' => $type);
         }
     }
     usort($fields, array(&$this, 'compare_FieldName'));
     return $fields;
 }