Esempio n. 1
0
 public function executeEdit()
 {
     $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo');
     $c = new Criteria();
     $c->add(JobPeer::CODE, $this->getModuleName());
     $job = JobPeer::doSelectOne($c);
     $acl = AclPeer::retrieveByPK($group_id, $job->getId());
     if (!$acl) {
         $this->forward('default', 'error404');
     }
     $this->can_add = $acl->getAddPriv() == 1;
     $this->can_edit = $acl->getEditPriv() == 1;
     $this->can_remove = $acl->getRemovePriv() == 1;
     $member_type = MemberTypePeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($member_type);
     $actions = array(array('name' => 'save', 'type' => 'submit', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value")));
     // if ($acl->getAddPriv()) array_push($actions, array('name'=>'copy','type'=>'submit', 'options'=>array('class'=>'save_button', 'onclick'=>"action_type.value=this.value")));
     if ($acl->getRemovePriv()) {
         array_push($actions, array('name' => 'delete', 'url' => 'member_type/delete?id=' . $member_type->getId(), 'color' => 'red'));
     }
     array_push($actions, array('name' => 'cancel', 'url' => 'member_type/list', 'color' => 'black'));
     $this->subtitle = $member_type->toString() . ' - id:' . $member_type->getId();
     $this->type = 'edit';
     $this->member_type = $member_type;
     $this->forward404Unless($this->member_type);
     $c = new Criteria();
     $this->member_jobs = MemberJobPeer::doSelect($c);
     foreach ($this->member_jobs as $member_job) {
         $c = new Criteria();
         $c->add(MemberJobPeer::PARENT, $member_job->getId());
         $c->add(MemberJobPeer::DISPLAY_MENU, true);
         $member_job->child = MemberJobPeer::doCount($c);
         $c = new Criteria();
         $c->add(MemberAclPeer::MEMBER_TYPE_ID, $this->member_type->getId(), Criteria::EQUAL);
         $c->add(MemberAclPeer::MEMBER_JOB_ID, $member_job->getId(), Criteria::EQUAL);
         $member_job->member_acl = MemberAclPeer::doSelectOne($c);
         $member_job->level = $member_job->getLevel();
         $member_job->order = $member_job->getMenuOrderRecursive();
     }
     function sortOrder($a, $b)
     {
         if ($a->order == $b->order) {
             return 0;
         }
         return $a->order < $b->order ? -1 : 1;
     }
     usort($this->member_jobs, 'sortOrder');
     $this->actions = $actions;
 }
Esempio n. 2
0
 public function countMemberJobsRelatedByParent($criteria = null, $distinct = false, $con = null)
 {
     include_once 'lib/model/om/BaseMemberJobPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     $criteria->add(MemberJobPeer::PARENT, $this->getId());
     return MemberJobPeer::doCount($criteria, $distinct, $con);
 }