コード例 #1
0
 private function getAssignableParents($dim_id, $otype_id)
 {
     $parents = Members::findAll(array("conditions" => array("`object_type_id` IN (\n\t\t\tSELECT `parent_object_type_id` FROM `" . DimensionObjectTypeHierarchies::instance()->getTableName() . "` WHERE `dimension_id` = ? AND `child_object_type_id` = ?\n\t\t)", $dim_id, $otype_id)));
     $parents_info = array();
     foreach ($parents as $parent) {
         $parents_info[] = array('id' => $parent->getId(), 'name' => $parent->getName());
     }
     $dim_obj_type = DimensionObjectTypes::findById(array('dimension_id' => $dim_id, 'object_type_id' => $otype_id));
     if ($dim_obj_type && $dim_obj_type->getIsRoot()) {
         array_unshift($parents_info, array('id' => 0, 'name' => lang('none')));
     }
     return $parents_info;
 }
コード例 #2
0
ファイル: Member.class.php プロジェクト: abhinay100/feng_app
 function canHaveParents()
 {
     $dim_id = $this->getDimensionId();
     $otype_id = $this->getObjectTypeId();
     $sql = "SELECT count(m.id) as cant from " . TABLE_PREFIX . "members m\r\n\t\t\t\tWHERE m.`object_type_id` IN (\r\n\t\t\t\t\tSELECT `parent_object_type_id` FROM `" . DimensionObjectTypeHierarchies::instance()->getTableName() . "`\r\n\t\t\t\t\tWHERE `dimension_id` = '{$dim_id}' AND `child_object_type_id` = '{$otype_id}'\r\n\t\t\t\t)";
     $rows = DB::executeAll($sql);
     $cant = $rows[0]['cant'];
     return $cant > 0;
 }
コード例 #3
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, 'DimensionObjectTypeHierarchies')) {
     return parent::paginate($arguments, $items_per_page, $current_page);
   } else {
     return DimensionObjectTypeHierarchies::instance()->paginate($arguments, $items_per_page, $current_page);
   } // if
 } // paginate
 /**
  * Return manager instance
  *
  * @access protected
  * @param void
  * @return DimensionObjectTypeHierarchies 
  */
 function manager()
 {
     if (!$this->manager instanceof DimensionObjectTypeHierarchyies) {
         $this->manager = DimensionObjectTypeHierarchies::instance();
     }
     return $this->manager;
 }