コード例 #1
0
 public function setup()
 {
     $scopes = sfBreadNavApplicationPeer::getScopeArray();
     $this->setWidgetSchema(new sfWidgetFormSchema(array('scope' => new sfWidgetFormSelect(array('choices' => $scopes), array('onchange' => 'scopeform.submit()')))));
     $this->setValidatorSchema(new sfValidatorSchema(array('scope' => new sfValidatorPass())));
     $this->widgetSchema->setNameFormat('%s');
     $this->widgetSchema->setLabel('scope', 'Active Menu');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     parent::setup();
 }
コード例 #2
0
ファイル: crudactions.class.php プロジェクト: anvaya/nckids
 public function executeDelete($request)
 {
     if (sfBreadNavPeer::scopeowner($request->getParameter('id'))) {
         $this->forward404Unless($sf_bread_nav_application = sfBreadNavApplicationPeer::retrieveByPk($request->getParameter('id')));
         $sf_bread_nav_application->delete();
         $this->redirect('sfBreadNavAdmin/list');
     } else {
         $this->setTemplate('breadnav');
         $this->message = "You need to be logged in to delete a menu.";
         return sfView::ERROR;
     }
 }
コード例 #3
0
ファイル: BasesfBreadNavPeer.php プロジェクト: anvaya/nckids
 /**
  * Selects a collection of sfBreadNav objects pre-filled with all related objects.
  *
  * @param      Criteria  $c
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of sfBreadNav objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     foreach (sfMixer::getCallables('BasesfBreadNavPeer:doSelectJoinAll:doSelectJoinAll') as $callable) {
         call_user_func($callable, 'BasesfBreadNavPeer', $c, $con);
     }
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     sfBreadNavPeer::addSelectColumns($c);
     $startcol2 = sfBreadNavPeer::NUM_COLUMNS - sfBreadNavPeer::NUM_LAZY_LOAD_COLUMNS;
     sfBreadNavApplicationPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (sfBreadNavApplicationPeer::NUM_COLUMNS - sfBreadNavApplicationPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(sfBreadNavPeer::SCOPE), array(sfBreadNavApplicationPeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = sfBreadNavPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = sfBreadNavPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = sfBreadNavPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             sfBreadNavPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined sfBreadNavApplication rows
         $key2 = sfBreadNavApplicationPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = sfBreadNavApplicationPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = sfBreadNavApplicationPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 sfBreadNavApplicationPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (sfBreadNav) to the collection in $obj2 (sfBreadNavApplication)
             $obj2->addsfBreadNav($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
コード例 #4
0
ファイル: sfBreadNavPeer.php プロジェクト: anvaya/nckids
 public static function scopeowner($scope)
 {
     //if config set to ownermenu only show users menus
     if (sfConfig::get('app_sfBreadNav_UserMenus', false)) {
         $c = new Criteria();
         $c->add(sfBreadNavApplicationPeer::ID, $scope);
         $c->add(sfBreadNavApplicationPeer::USER_ID, sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'sfGuardSecurityUser'));
         $result = sfBreadNavApplicationPeer::doCount($c);
         if ($result > 0) {
             return true;
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
コード例 #5
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = sfBreadNavApplicationPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setUserId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setApplication($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCss($arr[$keys[4]]);
     }
 }
コード例 #6
0
ファイル: actions.class.php プロジェクト: anvaya/nckids
 protected function setscope()
 {
     //use passed scope
     //if no scope passed get first scope
     //initialize scope form
     if ($this->getRequest()->hasParameter('scope')) {
         if (sfConfig::get('app_sfBreadNav_UserMenus', false)) {
             $this->scope = null;
             $c = new Criteria();
             $c->add(sfBreadNavApplicationPeer::ID, $this->getRequest()->getParameter('scope'));
             $c->add(sfBreadNavApplicationPeer::USER_ID, sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'sfGuardSecurityUser'));
             $tree = sfBreadNavApplicationPeer::doSelectOne($c);
             if ($tree) {
                 $this->scope = $this->getRequest()->getParameter('scope');
             }
         } else {
             $this->scope = $this->getRequest()->getParameter('scope');
         }
     } else {
         $c = new Criteria();
         //if config set to ownermenu only show users menus
         if (sfConfig::get('app_sfBreadNav_UserMenus', false)) {
             $c->add(sfBreadNavApplicationPeer::USER_ID, sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'sfGuardSecurityUser'));
         }
         $c->addAscendingOrderByColumn(sfBreadNavApplicationPeer::ID);
         $tree = sfBreadNavApplicationPeer::doSelectOne($c);
         if ($tree) {
             $this->scope = $tree->getId();
         } else {
             //scope = null
             $this->scope = null;
         }
     }
     $this->scopeform = new sfBreadNavScopeForm();
     $this->scopeform->setDefault('scope', $this->scope);
 }
コード例 #7
0
ファイル: BasesfBreadNav.php プロジェクト: anvaya/nckids
 /**
  * Get the associated sfBreadNavApplication object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     sfBreadNavApplication The associated sfBreadNavApplication object.
  * @throws     PropelException
  */
 public function getsfBreadNavApplication(PropelPDO $con = null)
 {
     if ($this->asfBreadNavApplication === null && $this->scope !== null) {
         $c = new Criteria(sfBreadNavApplicationPeer::DATABASE_NAME);
         $c->add(sfBreadNavApplicationPeer::ID, $this->scope);
         $this->asfBreadNavApplication = sfBreadNavApplicationPeer::doSelectOne($c, $con);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->asfBreadNavApplication->addsfBreadNavs($this);
         		 */
     }
     return $this->asfBreadNavApplication;
 }
コード例 #8
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(sfBreadNavApplicationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(sfBreadNavApplicationPeer::DATABASE_NAME);
         $criteria->add(sfBreadNavApplicationPeer::ID, $pks, Criteria::IN);
         $objs = sfBreadNavApplicationPeer::doSelect($criteria, $con);
     }
     return $objs;
 }