Example #1
0
 /**
  * Retourne le ou les élèves inscrits à un module
  *
  * @param Module $module Le module pour lequel on cherche les élèves.
  * @return array(Module)
  */
 public static function findAllByModule($module)
 {
     $moduleId = $module->getId();
     $mesEleves = array();
     $data = BaseSingleton::select('SELECT user.id, user.fichier_id, ' . 'user.type_user_id, user.prenom, user.nom, user.mail, ' . 'user.adresse, user.date_naissance, user.date_creation, ' . 'user.pseudo, user.password, user.affiche ' . 'FROM user_inscrire_module, user ' . 'WHERE user.id = user_inscrire_module.user_id ' . 'AND user_inscrire_module.module_id = ? ', array('i', &$moduleId));
     foreach ($data as $row) {
         $eleve = new User();
         $eleve->hydrate($row);
         $mesEleves[] = $eleve;
     }
     return $mesEleves;
 }
 /**
  *
  * @param Module $module        	
  * @return int id of the Module inserted in base. False if it didn't work.
  */
 public static function flush($module)
 {
     $moduleId = $module->getId();
     $title = $module->getTitle();
     $number = $module->getNumber();
     $price = $module->getPrice()->getId();
     if ($moduleId > 0) {
         $sql = 'UPDATE module m SET ' . 'm.title = ?, ' . 'm.number = ?, ' . 'm.PRICE_id_price = ?, ' . 'WHERE m.id_module = ?';
         $params = array('ssii', &$title, &$number, &$price, &$moduleId);
     } else {
         $sql = 'INSERT INTO module ' . '(title, number, PRICE_id_price) ' . 'VALUES(?, ?, ?) ';
         $params = array('ssi', &$title, &$number, &$price);
     }
     $idInsert = BaseSingleton::insertOrEdit($sql, $params);
     if ($idInsert !== false && $moduleId > 0) {
         $idInsert = $moduleId;
     }
     return $idInsert;
 }
Example #3
0
 /**
  * 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      Module $value A Module object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Module $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Example #4
0
 /**
  * Retourne tous les modules enregistrés.
  *
  * @return array[Module] Tous les objets dans un tableau.
  */
 public static function findAll()
 {
     $mesModules = array();
     $data = BaseSingleton::select('SELECT module.id as id, module.bareme_id as bareme_id, module.label as label, module.description as description, ' . 'module.date_creation as date_creation, module.number as number, module.affiche as affiche, assignment.id as assignment_id, exam.id as exam_id ' . 'FROM module, assignment, exam ' . 'WHERE module.id = assignment.module_id AND module.id = exam.module_id ' . 'GROUP BY module.id');
     foreach ($data as $row) {
         $module = new Module();
         $module->hydrate($row);
         $module->setRetryAssignment(self::findAllRattrapageAssign($module->getId()));
         $module->setRetryExam(self::findAllRattrapageExam($module->getId()));
         $mesModules[] = $module;
     }
     return $mesModules;
 }
Example #5
0
 /**
  * Checks and repairs the internal consistency of the object.
  *
  * This method is executed after an already-instantiated object is re-hydrated
  * from the database.  It exists to check any foreign keys to make sure that
  * the objects related to the current object are correct based on foreign key.
  *
  * You can override this method in the stub class, but you should always invoke
  * the base method from the overridden method (i.e. parent::ensureConsistency()),
  * in case your model changes.
  *
  * @throws PropelException
  */
 public function ensureConsistency()
 {
     if ($this->aModule !== null && $this->module_id !== $this->aModule->getId()) {
         $this->aModule = null;
     }
 }
 /**
  * function to generate the where condition for the user.
  * While displaying data in the list view data may appear from lower level users in the hierarchy.
  * For each user when the condition is to be generated, first get the subordinate user if any
  * And then generate the condition. Each table (entity - contacts,leads,potentials etc) will have 
  * iduser representing who is owner of the record.
  * @param string $entity_table_name
  * @param integer $idmodule
  * @param boolean $subordinate_users_data
  * @param integer $iduser
  * @see modules/User/User.class.php
  */
 public function get_user_where_condition($entity_table_name, $idmodule, $subordinate_users_data = true, $iduser = '')
 {
     if ($iduser == '') {
         $iduser = $_SESSION["do_user"]->iduser;
     }
     $module_data_share_permissions = $_SESSION["do_user"]->get_module_data_share_permissions();
     $where = '';
     //if($idmodule == 7 ) return " where 1=1 ";
     if ($subordinate_users_data === true) {
         if ($module_data_share_permissions[$idmodule] == 5) {
             return " AND `" . $entity_table_name . "`.`iduser` = " . $iduser;
         }
         if ($_SESSION["do_user"]->is_admin == 1) {
             return "";
         }
     }
     if ($module_data_share_permissions[$idmodule] == 1 || $module_data_share_permissions[$idmodule] == 2 || $module_data_share_permissions[$idmodule] == 3) {
         // if the datashare permission is public then display all
         $where = '';
     } elseif ($module_data_share_permissions[$idmodule] == 5) {
         $where = " AND `" . $entity_table_name . "`.`iduser` = " . $iduser;
     } else {
         if ($_SESSION["do_user"]->iduser > 0) {
             $subordinate_users = $_SESSION["do_user"]->get_subordinate_users();
             $user_to_groups = $_SESSION["do_user"]->get_user_associated_to_groups();
         } else {
             $do_user = new User();
             $do_group_user_rel = new GroupUserRelation();
             $subordinate_users = $do_user->get_subordinate_users_by_iduser($iduser);
             $user_to_groups = $do_group_user_rel->get_groups_by_user($iduser, $subordinate_users);
         }
         $group_qry = false;
         if (is_array($user_to_groups) && count($user_to_groups) > 0) {
             $do_module = new Module();
             $do_module->getId($idmodule);
             $module_name = $do_module->name;
             $entity_object = new $module_name();
             if ($entity_object->module_group_rel_table != '') {
                 $group_qry = true;
             }
         }
         if (is_array($subordinate_users) && count($subordinate_users) > 0 && $subordinate_users_data === true) {
             $unique_subordinate_users = array_unique($subordinate_users);
             $comma_seperated_subordinate_users = implode(",", $unique_subordinate_users);
             if ($group_qry === true) {
                 $where = " \n\t\t\t\t\tAND \n\t\t\t\t\t(\n\t\t\t\t\t\t( " . $entity_table_name . ".iduser = "******" \n\t\t\t\t\t\t\tOR " . $entity_table_name . ".iduser IN (" . $comma_seperated_subordinate_users . ") \n\t\t\t\t\t\t)\n\t\t\t\t\t\tOR (" . $entity_object->module_group_rel_table . ".idgroup in (" . implode(",", $user_to_groups) . ") )\n\t\t\t\t\t)";
             } else {
                 $where = " AND ( " . $entity_table_name . ".iduser = "******" OR " . $entity_table_name . ".iduser IN (" . $comma_seperated_subordinate_users . ") )";
             }
         } else {
             if ($group_qry === true) {
                 $where = " AND ( " . $entity_table_name . ".iduser = "******" OR " . $entity_object->module_group_rel_table . ".idgroup in (" . implode(",", $user_to_groups) . ") )";
             } else {
                 $where = " AND " . $entity_table_name . ".iduser = " . $iduser;
             }
         }
     }
     return $where;
 }
Example #7
0
File: test.php Project: sQcrm/sqcrm
<?php

// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* @author Abhik Chakraborty
*/
$idmodule = (int) $_GET["idmodule"];
$sqcrm_record_id = (int) $_GET["sqrecord"];
$plugin_position = (int) $_GET["plugin_position"];
$do_module = new Module();
$do_module->getId($idmodule);
$module_name = $do_module->name;
$do_module_object = new $module_name();
include_once 'view/plugin_view.php';
Example #8
0
 /**
  * add feed for the mentioned notes
  * @param integer $idnotes
  * @param string $note_content
  * @param integer $related_module_id
  * @param integer $sqcrm_record_id
  */
 public function add_mentions_feed($idnotes, $note_content, $related_module_id, $sqcrm_record_id)
 {
     if ($idnotes > 0) {
         $mentioned_feed_receiptents = array();
         preg_match_all("/(^|[^@\\w])@(\\w{1,15})\\b/im", $note_content, $mentioned_users);
         if (is_array($mentioned_users) && array_key_exists(2, $mentioned_users) && count($mentioned_users[2]) > 0) {
             $do_user = new \User();
             $active_users = $do_user->get_active_users();
             $current_user = 0;
             $active_users_key_as_username = array();
             foreach ($active_users as $key => $users) {
                 if ($users["iduser"] == $current_user) {
                     continue;
                 }
                 $active_users_key_as_username[$users["user_name"]] = array("iduser" => $users["iduser"], "firstname" => $users["firstname"], "lastname" => $users["lastname"], "email" => $users["email"]);
             }
             foreach ($mentioned_users[2] as $key => $val) {
                 if (array_key_exists($val, $active_users_key_as_username)) {
                     $mentioned_feed_receiptents[] = $active_users_key_as_username[$val["iduser"]];
                 }
             }
             if (is_array($mentioned_feed_receiptents) && count($mentioned_feed_receiptents) > 0) {
                 $do_feed_queue = new \LiveFeedQueue();
                 $do_crm_entity = new \CRMEntity();
                 $do_module = new \Module();
                 $do_module->getId($related_module_id);
                 $identifier = $do_crm_entity->get_entity_identifier($sqcrm_record_id, $do_module->name);
                 $related_identifier_data = array("related_identifier" => '', "related_identifier_idrecord" => $idnotes, "related_identifier_idmodule" => 8);
                 $do_feed_queue->add_feed_queue($sqcrm_record_id, $related_module_id, $identifier, 'note_mention', $mentioned_feed_receiptents, $related_identifier_data);
             }
         }
     }
 }