public function isValid($value)
 {
     $this->_setValue($value);
     $count = CcSubjsQuery::create()->filterByDbLogin($value)->count();
     if ($count != 0) {
         $this->_error(self::LOGIN);
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 public function validateLogin($data)
 {
     if (strlen($data['user_id']) == 0) {
         $count = CcSubjsQuery::create()->filterByDbLogin($data['login'])->count();
         if ($count != 0) {
             $this->getElement('login')->setErrors(array("login name is not unique."));
             return false;
         }
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      PropelPDO $con
  * @return     void
  * @throws     PropelException
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $ret = $this->preDelete($con);
         if ($ret) {
             CcSubjsQuery::create()->filterByPrimaryKey($this->getPrimaryKey())->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
Exemplo n.º 4
0
 /**
  * Set multiple metadata values using database columns as indexes.
  *
  * @param array $p_md
  *  example: $p_md['url'] = 'http://www.fake.com'
  */
 public function setDbColMetadata($p_md = null)
 {
     if (is_null($p_md)) {
         foreach ($this->_dbMD as $dbColumn => $propelColumn) {
             $method = "set{$propelColumn}";
             $this->_file->{$method}(null);
         }
     } else {
         $owner = $this->_file->getFkOwner();
         // if owner_id is already set we don't want to set it again.
         if (!$owner) {
             // no owner detected, we try to assign one.
             // if MDATA_OWNER_ID is not set then we default to the
             // first admin user we find
             if (!array_key_exists('owner_id', $p_md)) {
                 //$admins = Application_Model_User::getUsers(array('A'));
                 $admins = Application_Model_User::getUsersOfType('A');
                 if (count($admins) > 0) {
                     // found admin => pick first one
                     $owner = $admins[0];
                 }
             } else {
                 $user = CcSubjsQuery::create()->findPk($p_md['owner_id']);
                 if ($user) {
                     $owner = $user;
                 }
             }
             if ($owner) {
                 $this->_file->setDbOwnerId($owner->getDbId());
             } else {
                 Logging::info("Could not find suitable owner for file\n                        '" . $p_md['MDATA_KEY_FILEPATH'] . "'");
             }
         }
         # We don't want to process owner_id in bulk because we already
         # processed it in the code above. This is done because owner_id
         # needs special handling
         if (array_key_exists('owner_id', $p_md)) {
             unset($p_md['owner_id']);
         }
         foreach ($p_md as $dbColumn => $mdValue) {
             // don't blank out name, defaults to original filename on first
             // insertion to database.
             if ($dbColumn == "track_title" && (is_null($mdValue) || $mdValue == "")) {
                 continue;
             }
             # TODO : refactor string evals
             if (isset($this->_dbMD[$dbColumn])) {
                 $propelColumn = $this->_dbMD[$dbColumn];
                 $method = "set{$propelColumn}";
                 /* We need to set track_number to null if it is an empty string
                  * because propel defaults empty strings to zeros */
                 if ($dbColumn == "track_number" && empty($mdValue)) {
                     $mdValue = null;
                 }
                 $this->_file->{$method}($mdValue);
             }
         }
     }
     $this->_file->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
     $this->_file->save();
 }
Exemplo n.º 5
0
 /**
  * Get the associated CcSubjs object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     CcSubjs The associated CcSubjs object.
  * @throws     PropelException
  */
 public function getCcSubjs(PropelPDO $con = null)
 {
     if ($this->aCcSubjs === null && $this->userid !== null) {
         $this->aCcSubjs = CcSubjsQuery::create()->findPk($this->userid, $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->aCcSubjs->addCcSesss($this);
         		 */
     }
     return $this->aCcSubjs;
 }
Exemplo n.º 6
0
 public function getMetadata()
 {
     $subjs = CcSubjsQuery::create()->findPK($this->webstream->getDbCreatorId());
     $username = $subjs->getDbLogin();
     return array("name" => $this->webstream->getDbName(), "length" => $this->webstream->getDbLength(), "description" => $this->webstream->getDbDescription(), "login" => $username, "url" => $this->webstream->getDbUrl());
 }
Exemplo n.º 7
0
 public function passwordChangeAction()
 {
     //uses separate layout without a navigation.
     $this->_helper->layout->setLayout('login');
     $request = $this->getRequest();
     $token = $request->getParam("token", false);
     $user_id = $request->getParam("user_id", 0);
     $form = new Application_Form_PasswordChange();
     $auth = new Application_Model_Auth();
     $user = CcSubjsQuery::create()->findPK($user_id);
     //check validity of token
     if (!$auth->checkToken($user_id, $token, 'password.restore')) {
         Logging::debug("token not valid");
         $this->_helper->redirector('index', 'login');
     }
     if ($request->isPost() && $form->isValid($request->getPost())) {
         $user->setDbPass(md5($form->password->getValue()));
         $user->save();
         $auth->invalidateTokens($user, 'password.restore');
         $zend_auth = Zend_Auth::getInstance();
         $zend_auth->clearIdentity();
         $authAdapter = Application_Model_Auth::getAuthAdapter();
         $authAdapter->setIdentity($user->getDbLogin())->setCredential($form->password->getValue());
         $zend_auth->authenticate($authAdapter);
         //all info about this user from the login table omit only the password
         $userInfo = $authAdapter->getResultRowObject(null, 'password');
         //the default storage is a session with namespace Zend_Auth
         $authStorage = $zend_auth->getStorage();
         $authStorage->write($userInfo);
         $this->_helper->redirector('index', 'showbuilder');
     }
     $this->view->form = $form;
 }
Exemplo n.º 8
0
 public static function getUsersOfType($type)
 {
     return CcSubjsQuery::create()->filterByDbType($type)->find();
 }
Exemplo n.º 9
0
 /**
  * Returns a new CcSubjsQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return    CcSubjsQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof CcSubjsQuery) {
         return $criteria;
     }
     $query = new CcSubjsQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Exemplo n.º 10
0
 public function validateLogin($p_login, $p_userId)
 {
     $count = CcSubjsQuery::create()->filterByDbLogin($p_login)->filterByDbId($p_userId, Criteria::NOT_EQUAL)->count();
     if ($count != 0) {
         $this->getElement('cu_login')->setErrors(array(_("Login name is not unique.")));
         return false;
     } else {
         return true;
     }
 }
Exemplo n.º 11
0
 public static function GetUserID($login)
 {
     $user = CcSubjsQuery::create()->findOneByDbLogin($login);
     if (is_null($user)) {
         return -1;
     } else {
         return $user->getDbId();
     }
 }