Exemplo n.º 1
0
 /**
  * Verify if exists the title of a Department
  *
  * @param string $departmentTitle      Title
  * @param string $departmentUidExclude Unique id of Department to exclude
  *
  * return bool Return true if exists the title of a Department, false otherwise
  */
 public function existsTitle($departmentTitle, $departmentUidExclude = "")
 {
     try {
         $delimiter = \DBAdapter::getStringDelimiter();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\DepartmentPeer::DEP_UID);
         $criteria->addAlias("CT", \ContentPeer::TABLE_NAME);
         $arrayCondition = array();
         $arrayCondition[] = array(\DepartmentPeer::DEP_UID, "CT.CON_ID", \Criteria::EQUAL);
         $arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "DEPO_TITLE" . $delimiter, \Criteria::EQUAL);
         $arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
         $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
         if ($departmentUidExclude != "") {
             $criteria->add(\DepartmentPeer::DEP_UID, $departmentUidExclude, \Criteria::NOT_EQUAL);
         }
         $criteria->add("CT.CON_VALUE", $departmentTitle, \Criteria::EQUAL);
         $rsCriteria = \DepartmentPeer::doSelectRS($criteria);
         return $rsCriteria->next() ? true : false;
     } catch (\Exception $e) {
         throw $e;
     }
 }
Exemplo n.º 2
0
 public function getOwnersByType($data)
 {
     $this->setResponseType('json');
     $result = new stdclass();
     $result->status = 'OK';
     try {
         switch ($data->type) {
             case 'EVERYBODY':
                 $result->total = 0;
                 $result->owners = array();
                 break;
             case 'USER':
                 require_once 'classes/model/Users.php';
                 $users = array();
                 $usersInstance = new Users();
                 $allUsers = $usersInstance->getAll();
                 foreach ($allUsers->data as $user) {
                     $users[] = array('OWNER_UID' => $user['USR_UID'], 'OWNER_NAME' => $user['USR_FIRSTNAME'] . ' ' . $user['USR_LASTNAME']);
                 }
                 usort($users, function ($str1, $str2) {
                     return strcmp(strtolower($str1["OWNER_NAME"]), strtolower($str2["OWNER_NAME"]));
                 });
                 $result->total = $allUsers->totalCount;
                 $result->owners = $users;
                 break;
             case 'DEPARTMENT':
                 require_once 'classes/model/Department.php';
                 require_once 'classes/model/Content.php';
                 $departments = array();
                 //SELECT
                 $criteria = new Criteria('workflow');
                 $criteria->setDistinct();
                 $criteria->addSelectColumn(DepartmentPeer::DEP_UID);
                 $criteria->addSelectColumn(ContentPeer::CON_VALUE);
                 //FROM
                 $conditions = array();
                 $conditions[] = array(DepartmentPeer::DEP_UID, ContentPeer::CON_ID);
                 $conditions[] = array(ContentPeer::CON_CATEGORY, DBAdapter::getStringDelimiter() . 'DEPO_TITLE' . DBAdapter::getStringDelimiter());
                 $conditions[] = array(ContentPeer::CON_LANG, DBAdapter::getStringDelimiter() . 'en' . DBAdapter::getStringDelimiter());
                 $criteria->addJoinMC($conditions, Criteria::LEFT_JOIN);
                 //WHERE
                 $criteria->add(DepartmentPeer::DEP_STATUS, 'ACTIVE');
                 //ORDER BY
                 $criteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
                 $dataset = DepartmentPeer::doSelectRS($criteria);
                 $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                 $dataset->next();
                 while ($row = $dataset->getRow()) {
                     $departments[] = array('OWNER_UID' => $row['DEP_UID'], 'OWNER_NAME' => $row['CON_VALUE']);
                     $dataset->next();
                 }
                 $result->total = DepartmentPeer::doCount($criteria);
                 $result->owners = $departments;
                 break;
             case 'GROUP':
                 require_once 'classes/model/Groupwf.php';
                 require_once 'classes/model/Content.php';
                 $groups = array();
                 //SELECT
                 $criteria = new Criteria('workflow');
                 $criteria->setDistinct();
                 $criteria->addSelectColumn(GroupwfPeer::GRP_UID);
                 $criteria->addSelectColumn(ContentPeer::CON_VALUE);
                 //FROM
                 $conditions = array();
                 $conditions[] = array(GroupwfPeer::GRP_UID, ContentPeer::CON_ID);
                 $conditions[] = array(ContentPeer::CON_CATEGORY, DBAdapter::getStringDelimiter() . 'GRP_TITLE' . DBAdapter::getStringDelimiter());
                 $conditions[] = array(ContentPeer::CON_LANG, DBAdapter::getStringDelimiter() . 'en' . DBAdapter::getStringDelimiter());
                 $criteria->addJoinMC($conditions, Criteria::LEFT_JOIN);
                 //WHERE
                 $criteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
                 //ORDER BY
                 $criteria->addAscendingOrderByColumn(ContentPeer::CON_VALUE);
                 $dataset = GroupwfPeer::doSelectRS($criteria);
                 $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                 $dataset->next();
                 while ($row = $dataset->getRow()) {
                     $groups[] = array('OWNER_UID' => $row['GRP_UID'], 'OWNER_NAME' => $row['CON_VALUE']);
                     $dataset->next();
                 }
                 $result->total = GroupwfPeer::doCount($criteria);
                 $result->owners = $groups;
                 break;
         }
     } catch (Exception $error) {
         $result->status = 'ERROR';
         $result->message = $error->getMessage();
     }
     return $result;
 }
Exemplo n.º 3
0
    /**

     * get all department

     *

     * @param none

     * @return $result will return an object

     */

    public function departmentList ()

    {

        try {

            $result = array ();

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( DepartmentPeer::DEP_STATUS, 'ACTIVE' );

            $oDataset = DepartmentPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();



            while ($aRow = $oDataset->getRow()) {

                $oDepartment = new Department();

                $aDepartment = $oDepartment->Load( $aRow['DEP_UID'] );

                $node['guid'] = $aRow['DEP_UID'];

                $node['name'] = $aDepartment['DEPO_TITLE'];

                $node['parentUID'] = $aDepartment['DEP_PARENT'];

                $node['dn'] = $aDepartment['DEP_LDAP_DN'];



                //get the users from this department

                $c = new Criteria();

                $c->clearSelectColumns();

                $c->addSelectColumn( 'COUNT(*)' );

                $c->add( UsersPeer::DEP_UID, $aRow['DEP_UID'] );

                $rs = UsersPeer::doSelectRS( $c );

                $rs->next();

                $row = $rs->getRow();

                $count = $row[0];



                $node['users'] = $count;

                $result[] = $node;

                $oDataset->next();

            }



            return $result;

        } catch (Exception $e) {

            $result[] = array ('guid' => $e->getMessage(),'name' => $e->getMessage()

            );



            return $result;

        }

    }
Exemplo n.º 4
0
 public static function doSelect(Criteria $criteria, $con = null)
 {
     return DepartmentPeer::populateObjects(DepartmentPeer::doSelectRS($criteria, $con));
 }
Exemplo n.º 5
0
 *
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 */
if (($RBAC_Response = $RBAC->userCanAccess("PM_USERS")) != 1) {
    return $RBAC_Response;
}
require_once 'classes/model/Department.php';
require_once 'classes/model/Users.php';
$oDpto = new Department();
if (!isset($_POST['DEP_UID'])) {
    return;
}
$ocriteria = new Criteria('workflow');
$ocriteria->addSelectColumn(DepartmentPeer::DEP_MANAGER);
$ocriteria->add(DepartmentPeer::DEP_UID, $_POST['DEP_UID']);
$oDataset = DepartmentPeer::doSelectRS($ocriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aRow = $oDataset->getRow();
$oCriteria1 = new Criteria('workflow');
$oCriteria1->add(UsersPeer::USR_REPORTS_TO, $aRow['DEP_MANAGER'], Criteria::EQUAL);
$oCriteria2 = new Criteria('workflow');
$oCriteria2->add(UsersPeer::USR_REPORTS_TO, '');
BasePeer::doUpdate($oCriteria1, $oCriteria2, Propel::getConnection('workflow'));
$oCriteriaA = new Criteria('workflow');
$oCriteriaA->add(UsersPeer::DEP_UID, $_POST['DEP_UID'], Criteria::EQUAL);
$oCriteriaB = new Criteria('workflow');
$oCriteriaB->add(UsersPeer::DEP_UID, '');
BasePeer::doUpdate($oCriteriaA, $oCriteriaB, Propel::getConnection('workflow'));
$oDpto->remove(urldecode($_POST['DEP_UID']));
Exemplo n.º 6
0
 public function getDepartmentsForUser($userUid)
 {
     $criteria = new Criteria('workflow');
     $criteria->addSelectColumn(UsersPeer::DEP_UID);
     $criteria->addAsColumn('DEP_TITLE', 'C.CON_VALUE');
     $criteria->addAlias('C', 'CONTENT');
     $criteria->addJoin(UsersPeer::DEP_UID, DepartmentPeer::DEP_UID, Criteria::LEFT_JOIN);
     $delimiter = DBAdapter::getStringDelimiter();
     $conditions = array();
     $conditions[] = array(DepartmentPeer::DEP_UID, 'C.CON_ID');
     $conditions[] = array('C.CON_CATEGORY', $delimiter . 'DEPO_TITLE' . $delimiter);
     $conditions[] = array('C.CON_LANG', $delimiter . SYS_LANG . $delimiter);
     $criteria->addJoinMC($conditions, Criteria::LEFT_JOIN);
     $criteria->add(UsersPeer::USR_UID, $userUid);
     $criteria->add(UsersPeer::DEP_UID, '', Criteria::NOT_EQUAL);
     $dataset = DepartmentPeer::doSelectRS($criteria);
     $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $dataset->next();
     $departments = array();
     while ($row = $dataset->getRow()) {
         if (!isset($departments[$row['DEP_UID']])) {
             $departments[$row['DEP_UID']] = $row;
         }
         $dataset->next();
     }
     return $departments;
 }
Exemplo n.º 7
0
 public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
 {
     $criteria = clone $criteria;
     $criteria->clearSelectColumns()->clearOrderByColumns();
     if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
         $criteria->addSelectColumn(DepartmentPeer::COUNT_DISTINCT);
     } else {
         $criteria->addSelectColumn(DepartmentPeer::COUNT);
     }
     foreach ($criteria->getGroupByColumns() as $column) {
         $criteria->addSelectColumn($column);
     }
     $rs = DepartmentPeer::doSelectRS($criteria, $con);
     if ($rs->next()) {
         return $rs->getInt(1);
     } else {
         return 0;
     }
 }