/**
  * Returns a new OrganizationQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   OrganizationQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return OrganizationQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof OrganizationQuery) {
         return $criteria;
     }
     $query = new OrganizationQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Esempio n. 2
0
 public function getPendingOrganizations()
 {
     return OrganizationQuery::create()->leftJoin('UserOrganization')->where('UserOrganization.InviteToken <> ""')->withColumn('UserOrganization.InviteToken', 'InviteToken')->where('UserOrganization.UserId = ?', $this->getId())->find();
 }
Esempio n. 3
0
 /**
  * Get the associated Organization object
  *
  * @param PropelPDO $con Optional Connection object.
  * @param $doQuery Executes a query to get the object if required
  * @return Organization The associated Organization object.
  * @throws PropelException
  */
 public function getOrganization(PropelPDO $con = null, $doQuery = true)
 {
     if ($this->aOrganization === null && ($this->organization_id !== "" && $this->organization_id !== null) && $doQuery) {
         $this->aOrganization = OrganizationQuery::create()->findPk($this->organization_id, $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->aOrganization->addCharts($this);
            */
     }
     return $this->aOrganization;
 }
Esempio n. 4
0
 /**
  * Gets the number of Organization objects related by a many-to-many relationship
  * to the current object by way of the plugin_organization cross-reference table.
  *
  * @param Criteria $criteria Optional query object to filter the query
  * @param boolean $distinct Set to true to force count distinct
  * @param PropelPDO $con Optional connection object
  *
  * @return int the number of related Organization objects
  */
 public function countOrganizations($criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if (null === $this->collOrganizations || null !== $criteria) {
         if ($this->isNew() && null === $this->collOrganizations) {
             return 0;
         } else {
             $query = OrganizationQuery::create(null, $criteria);
             if ($distinct) {
                 $query->distinct();
             }
             return $query->filterByPlugin($this)->count($con);
         }
     } else {
         return count($this->collOrganizations);
     }
 }
Esempio n. 5
0
            } else {
                if ($op == '' || $op == 'toggle') {
                    $org->addPlugin($plugin);
                }
            }
            $org->save();
            ok(array('active' => $org->hasPlugin($plugin)));
        }
    });
})->conditions(array('op' => '(remove|add|toggle|config)'));
/*
 * get charts of an organization
 */
$app->get('/organizations/:id/charts', function ($org_id) use($app) {
    $user = DatawrapperSession::getUser();
    $org = OrganizationQuery::create()->findPk($org_id);
    if ($org) {
        if ($org->hasUser($user) || $user->isAdmin()) {
            $query = ChartQuery::create()->filterByDeleted(false)->orderByLastModifiedAt(Criteria::DESC)->filterByOrganization($org);
            // filter by visualization
            $vis = $app->request()->get('vis');
            if (isset($vis)) {
                $vis = explode(',', $vis);
                $conds = array();
                foreach ($vis as $v) {
                    $query->condition($conds[] = 'c' . count($conds), 'Chart.Type = ?', $v);
                }
                $query->where($conds, 'or');
            }
            // filter by month
            $months = $app->request()->get('months');
Esempio n. 6
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param PropelPDO $con
  * @return void
  * @throws PropelException
  * @throws Exception
  * @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(OrganizationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = OrganizationQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
Esempio n. 7
0
 public function hasPlugin($plugin)
 {
     return OrganizationQuery::create()->filterById($this->getId())->filterByPlugin($plugin)->count() > 0;
 }