/**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      RoleNotification $value A RoleNotification object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(RoleNotification $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Example #2
0
    function executeAddrole(sfWebRequest $request)
    {
        /*$c = new Criteria();
            $c->add(RoleNotificationPeer::ID, $request->getParameter('rnid'));
            RoleNotificationPeer::doDelete($c);	
        	*/
        if (!$this->getUser()->hasCredential(array('Administrator'), false)) {
            $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
            $this->redirect('dashboard/index');
        }
        $isEmail = $request->getParameter('isemail');
        $isInstrument = $request->getParameter('isinstrument');
        $roleId = $request->getParameter('roleid');
        $misType = $request->getParameter('mistype');
        $divname = $request->getParameter('divname');
        $c = new Criteria();
        $c->add(RoleNotificationPeer::ROLE_ID, $roleId);
        $c->add(RoleNotificationPeer::MID, $misType);
        $role = RoleNotificationPeer::doSelect($c);
        $last_id = "";
        if (count($role) == 0) {
            $rolenotification = new RoleNotification();
            $rolenotification->setMid($misType);
            $rolenotification->setRoleId($roleId);
            $rolenotification->setNotification($this->getNotification($isEmail, $isInstrument));
            $rolenotification->save();
            $last_id = $rolenotification->getId();
        }
        if (strlen($last_id) > 0) {
            $c = new Criteria();
            $c->add(RoleNotificationPeer::ID, $last_id);
            $notification = RoleNotificationPeer::doSelectJoinAll($c);
            foreach ($notification as $nod) {
                /////////////////////////
                if ($nod->getNotification() == "3") {
                    $email = "checked";
                    $instnel = "checked";
                } else {
                    if ($nod->getNotification() == "2") {
                        $email = "";
                        $instnel = "checked";
                    } else {
                        if ($nod->getNotification() == "1") {
                            $email = "checked";
                            $instnel = "";
                        } else {
                            $email = "";
                            $instnel = "";
                        }
                    }
                }
                /////////////////////////
                $str = '<div id="rolid' . $last_id . '">' . '<table><tr><td width="' . '200' . '">' . $nod->getRole()->getTitle() . '&nbsp;<span onclick="delRole(' . $nod->getId() . ')" style="cursor:pointer;color:red;"><b>X</b></span>
							&nbsp;&nbsp;&nbsp;<span>' . '</td><td>' . '<input name="isEmail" id="isEmail" value="1" type="checkbox" ' . $email . ' /> Email<input name="isInstrumental" id="isInstrumental" value="1" type="checkbox" ' . $instnel . ' /> Instrument Panel' . '<a href="#" class="link-edit" onclick="editrole(' . $nod->getId() . ',' . '"$divname"' . '); return false;" />Edit</a>' . '</td><tr></table>' . '</div>' . '<div id="' . $divname . '">' . '</div>';
            }
            return $this->renderText($str);
        } else {
            return $this->renderText("1");
        }
        //1 for unsuccess
    }