コード例 #1
0
ファイル: class_auth.inc.php プロジェクト: Bremaweb/streber-1
 public function setCurUserAsAnonymous($cookie_string = NULL)
 {
     measure_start('include Person');
     require_once confGet('DIR_STREBER') . "db/class_person.inc.php";
     measure_stop('include Person');
     global $PH;
     if (!($au = confGet('ANONYMOUS_USER'))) {
         return NULL;
     }
     if (!($user = Person::getById($au))) {
         new FeedbackMessage(__("Invalid anonymous user"));
         log_message(" Failed: setCurUserAsAnonymous::getById() without result", LOG_MESSAGE_DEBUG);
         return NULL;
     }
     if (!$user->can_login) {
         new FeedbackWarning(__("Anonymous account has been disabled. "));
         log_message(" Failed: Anonymous account disabled", LOG_MESSAGE_DEBUG);
         return false;
     }
     ### disable rendering for traffic exhaustive browsers ###
     if ($this->isUglyCrawler()) {
         exit;
     }
     ### success ###
     $this->cur_user = $user;
     $user->last_login = getGMTString();
     $this->cur_user->update(array('last_login'), false);
     return $user;
 }
コード例 #2
0
 /**
  * insert a new organization in database
  * @param array A well format organization 
  * @return a json result as an array. 
  */
 public static function insert($organization, $userId)
 {
     $newOrganization = Organization::getAndCheckOrganization($organization);
     //Manage tags : save any inexistant tag to DB
     if (isset($newOrganization["tags"])) {
         $newOrganization["tags"] = Tags::filterAndSaveNewTags($newOrganization["tags"]);
     }
     //Add the user creator of the organization in the system
     $newOrganization["creator"] = $userId;
     //Insert the organization
     PHDB::insert(Organization::COLLECTION, $newOrganization);
     if (isset($newOrganization["_id"])) {
         $newOrganizationId = (string) $newOrganization["_id"];
     } else {
         throw new CTKException(Yii::t("organisation", "Problem inserting the new organization"));
     }
     //Add the creator as the first member and admin of the organization
     Link::addMember($newOrganizationId, Organization::COLLECTION, $userId, PHType::TYPE_CITOYEN, $userId, true);
     //send Notification Email
     $creator = Person::getById($userId);
     Mail::newOrganization($creator, $newOrganization);
     //TODO ???? : add an admin notification
     Notification::saveNotification(array("type" => "Created", "user" => $newOrganizationId));
     $newOrganization = Organization::getById($newOrganizationId);
     return array("result" => true, "msg" => "Votre organisation est communectée.", "id" => $newOrganizationId, "newOrganization" => $newOrganization);
 }
コード例 #3
0
 function render_tr(&$obj, $style = "")
 {
     global $PH;
     global $auth;
     global $COMMENTTYPE_NAMES;
     if (!isset($obj) || !$obj instanceof Comment) {
         trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
         return;
     }
     $style_cur_user = '';
     if ($obj->created_by != 0 && ($person = Person::getById($obj->created_by))) {
         if ($obj->created_by == $auth->cur_user->id) {
             $style_cur_user = '******';
         }
     }
     $column_poster = '<td class="details ' . $style_cur_user . '">';
     if ($obj->created_by != 0 && ($person = Person::getById($obj->created_by))) {
         $column_poster .= '<p class="poster">' . $person->getLink() . '</p>';
     }
     if (!$obj->view_collapsed) {
         ### time ###
         $p_time = renderDateHtml($obj->time);
         $column_poster .= "<span class=date>{$p_time}</span>";
         ### pub level if not open ###
         if ($obj->pub_level != PUB_LEVEL_OPEN) {
             global $g_pub_level_names;
             $column_poster .= "<br>(" . $g_pub_level_names[$obj->pub_level] . ')<br>';
         }
         require_once confGet('DIR_STREBER') . "db/db_itemchange.inc.php";
         $versions = ItemVersion::getFromItem($obj);
         if (count($versions) > 1) {
             $column_poster .= "<br>" . $PH->getLink('itemViewDiff', sprintf(__("version %s"), count($versions)), array('item' => $obj->id));
         }
         $column_poster .= "<div class=edit_functions>";
         # if current user is the creator of the comment
         if ($obj->created_by == $auth->cur_user->id) {
             if ($obj->isEditable()) {
                 $column_poster .= $PH->getLink('commentEdit', __('Edit'), array('comment' => $obj->id));
                 $column_poster .= $PH->getLink('commentsDelete', __('Delete'), array('comment' => $obj->id));
             }
         } else {
             ### check sufficient rights ###
             if ($parent_task = Task::getEditableById($obj->task)) {
                 # have to send the task-id otherwise the reply function doesn't work
                 $column_poster .= $PH->getLink('commentNew', __('Reply'), array('comment' => $obj->id, 'parent_task' => $obj->task));
                 if ($obj->pub_level != PUB_LEVEL_OPEN) {
                     $column_poster .= $PH->getLink('itemsSetPubLevel', __('Publish'), array('item' => $obj->id, 'item_pub_level' => PUB_LEVEL_OPEN));
                 }
             }
         }
         $column_poster .= "</div>";
     }
     $column_poster .= "</td>";
     print $column_poster;
 }
コード例 #4
0
 public function run($user)
 {
     $controller = $this->getController();
     $account = Person::getById($user);
     //TODO : move code below to the model Person
     if ($account) {
         Person::saveUserSessionData($user, $account["email"], array("name" => $account["name"]));
         //remove tobeactivated attribute on account
         PHDB::update(PHType::TYPE_CITOYEN, array("_id" => new MongoId($user)), array('$unset' => array("tobeactivated" => "")));
         /*Notification::saveNotification(array("type"=>NotificationType::NOTIFICATION_ACTIVATED,
           "user"=>$account["_id"]));*/
     }
     //TODO : add notification to the cities,region,departement info panel
     //TODO : redirect to monPH page , inciter le rezotage local
     $controller->redirect(Yii::app()->homeUrl);
 }
コード例 #5
0
ファイル: file.php プロジェクト: Jonathan-Law/fhd
 public static function addTag($pid = NULL, $fid = NULL, $type = 'other')
 {
     $database = cbSQLConnect::adminConnect('both');
     if (isset($database)) {
         $person = recast("Person", Person::getById($pid));
         $result = array();
         if ($pid != NULL) {
             $result[] = saveTags($person->selectName(), "file", $fid, "tag_after_file_upload", $pid, $type, URL . $link);
         } else {
             $result[] = saveTags($person->selectName(), "file", $fid, "tag_after_file_upload", -1, $type, URL . $link);
         }
         // $fields = array();
         // $fields['name'] = $tag;
         // $fields['ftable'] = $table;
         // $fields['fid'] = $id;
         // $fields['category'] = $group;
         // $fields['personid'] = $personId > 0? $personId : -1;
         // $fields['type'] = $type;
         return $result;
     }
 }
コード例 #6
0
 public function run($type = null, $id = null)
 {
     $controller = $this->getController();
     $controller->title = "Timeline";
     $controller->subTitle = "NEWS comes from everywhere, and from anyone.";
     $controller->pageTitle = "Communecter - Timeline Globale";
     //mongo search cmd : db.news.find({created:{'$exists':1}})
     if ($type == Project::COLLECTION) {
         $controller->toolbarMBZ = array("<a href='" . Yii::app()->createUrl("/" . $controller->module->id . "/project/dashboard/id/" . $id) . "'><i class='fa fa-lightbulb-o'></i>Project</a>");
         $project = Project::getById($id);
         $controller->title = $project["name"] . "'s Timeline";
         $controller->subTitle = "Every Project is story to be told.";
         $controller->pageTitle = "Communecter - " . $controller->title;
     } else {
         if ($type == Person::COLLECTION) {
             $controller->toolbarMBZ = array("<a href='" . Yii::app()->createUrl("/" . $controller->module->id . "/person/dashboard/id/" . $id) . "'><i class='fa fa-user'></i>Person</a>");
             $person = Person::getById($id);
             $controller->title = $person["name"] . "'s Timeline";
             $controller->subTitle = "Everyone has story to tell.";
             $controller->pageTitle = "Communecter - " . $controller->title;
         }
     }
     $where = array("created" => array('$exists' => 1), "text" => array('$exists' => 1));
     if (isset($type)) {
         $where["type"] = $type;
     }
     if (isset($id)) {
         $where["id"] = $id;
     }
     //var_dump($where);
     $news = News::getWhereSortLimit($where, array("created" => -1), 30);
     if (Yii::app()->request->isAjaxRequest) {
         echo $controller->renderPartial("index", array("news" => $news, "userCP" => Yii::app()->session['userCP']), true);
     } else {
         $controller->render("index", array("news" => $news, "userCP" => Yii::app()->session['userCP']));
     }
 }
コード例 #7
0
 /**
  * @depends testCreateNewActivity
  */
 public function testGetByTypeAndModelIdAndPersonIdAndUrl()
 {
     $type = AutoresponderItemActivity::TYPE_OPEN;
     $url = null;
     $persons = Person::getAll();
     $this->assertNotEmpty($persons);
     $person = $persons[0];
     $autoresponderItems = AutoresponderItem::getAll();
     $this->assertNotEmpty($autoresponderItems);
     $autoresponderItem = $autoresponderItems[0];
     $activities = AutoresponderItemActivity::getByTypeAndModelIdAndPersonIdAndUrl($type, $autoresponderItem->id, $person->id, $url);
     $this->assertNotEmpty($activities);
     $this->assertCount(1, $activities);
     $activity = $activities[0];
     $this->assertEquals($type, $activity->type);
     $this->assertEquals(1, $activity->quantity);
     $this->assertEquals($person, $activity->person);
     $this->assertEquals($autoresponderItem, $activity->autoresponderItem);
     // now try same thing but with a url this time.
     $contact = Contact::getByName('contact 02 contact 02son');
     $personId = $contact[0]->getClassId('Person');
     $person = Person::getById($personId);
     $type = AutoresponderItemActivity::TYPE_CLICK;
     $url = 'http://www.zurmo.com';
     $activities = AutoresponderItemActivity::getByTypeAndModelIdAndPersonIdAndUrl($type, $autoresponderItem->id, $personId, $url);
     $this->assertNotEmpty($activities);
     $this->assertCount(1, $activities);
     $activity = $activities[0];
     $this->assertEquals($type, $activity->type);
     $this->assertEquals(1, $activity->quantity);
     $this->assertEquals($person, $activity->person);
     $this->assertEquals($autoresponderItem, $activity->autoresponderItem);
 }
コード例 #8
0
 /**
  * give person-object to this projectProject
  */
 public function getPerson()
 {
     return Person::getById($this->person);
 }
コード例 #9
0
ファイル: individual2.php プロジェクト: Jonathan-Law/fhd
            foreach ($mmother as $key) {
                $temp_person = Person::getById($key->parentId);
                if ($temp_person->sex == 'male') {
                    $data["response"]["mmparents"]["father"][] = $temp_person;
                } else {
                    $data["response"]["mmparents"]["mother"][] = $temp_person;
                }
            }
            foreach ($ffather as $key) {
                $temp_person = Person::getById($key->parentId);
                if ($temp_person->sex == 'male') {
                    $data["response"]["ffparents"]["father"][] = $temp_person;
                } else {
                    $data["response"]["ffparents"]["mother"][] = $temp_person;
                }
            }
            foreach ($fmother as $key) {
                $temp_person = Person::getById($key->parentId);
                if ($temp_person->sex == 'male') {
                    $data["response"]["fmparents"]["father"][] = $temp_person;
                } else {
                    $data["response"]["fmparents"]["mother"][] = $temp_person;
                }
            }
        } else {
            $data["response"] = "There was no id";
        }
        echo json_encode($data);
        exit;
    }
}
コード例 #10
0
 public static function createNewActivity($type, $modelId, $personId, $url = null, $sourceIP = null, $relatedModel = null)
 {
     $relationName = static::getRelationName();
     if (!isset($relatedModel)) {
         $relatedModelClassName = static::getRelatedModelClassName();
         $relatedModel = $relatedModelClassName::getById(intval($modelId));
     }
     $className = get_called_class();
     $activity = new $className();
     $activity->quantity = 1;
     $activity->type = $type;
     $activity->latestSourceIP = $sourceIP;
     if ($url) {
         $emailMessageUrl = new EmailMessageUrl();
         $emailMessageUrl->url = $url;
         $activity->emailMessageUrl = $emailMessageUrl;
     }
     $person = Person::getById(intval($personId));
     if (!$person) {
         throw new NotFoundException();
     }
     $activity->person = $person;
     $activity->{$relationName} = $relatedModel;
     if (!$activity->save()) {
         throw new FailedToSaveModelException();
     } else {
         static::createNewOpenActivityForFirstClickTrackingActivity($type, $personId, $relatedModel, $sourceIP);
         return true;
     }
 }
コード例 #11
0
 protected function getContactByPersonId($personId)
 {
     $person = Person::getById(intval($personId));
     $contact = $person->castDown(array('Contact'));
     return $contact;
 }
コード例 #12
0
 function getPerson()
 {
     require_once confGet('DIR_STREBER') . 'db/class_person.inc.php';
     if ($this->person) {
         $person = Person::getById($this->person);
     } else {
         $person = Person::getById($this->created_by);
     }
     return $person;
 }
コード例 #13
0
ファイル: login.inc.php プロジェクト: Bremaweb/streber-1
/**
* Logout the current user and remove cookies @ingroup pages
*/
function logout()
{
    global $PH;
    global $auth;
    ### kill cookie ###
    $auth->removeUserCookie();
    $PH->cur_page_md5 = NULL;
    /**
     * keep date of last logout
     * NOTE: the cur_user-object might be no longer up to date (think about person submit).
     * so we get the latest version from the database to update the last_login-field
     */
    if ($cur_user = Person::getById($auth->cur_user->id)) {
        $cur_user->cookie_string = $auth->cur_user->calcCookieString();
        $cur_user->last_logout = getGMTString();
        $cur_user->update();
    }
    ### go to login-page ####
    $PH->messages[] = "Logged out";
    $PH->show('loginForm');
    #header("location:index.php");
    if ($auth->cur_user) {
        $nickname = $auth->cur_user->nickname;
    } else {
        $nickname = '_nobody_';
    }
    log_message("'" . $nickname . "' logged out from:" . getServerVar("REMOTE_ADDR", true), LOG_MESSAGE_LOGOUT);
    require_once confGet('DIR_STREBER') . 'std/mail.inc.php';
    Notifier::sendNotifications();
}
コード例 #14
0
ファイル: favorites.php プロジェクト: Jonathan-Law/fhd
 protected function create()
 {
     $database = cbSQLConnect::connect('object');
     if (isset($database)) {
         $fields = self::$db_fields;
         $data = array();
         foreach ($fields as $key) {
             if ($this->{$key}) {
                 $data[$key] = $this->{$key};
             } else {
                 $data[$key] = NULL;
             }
         }
         // return $data;
         $insert = $database->SQLInsert($data, "favorites");
         // return true if sucess or false
         if ($insert) {
             $person = Person::getById($this->person_id);
             $person = recast("Person", $person);
             $user = User::getUserById($this->user_id);
             $user = recast("Person", $user);
             $to = "*****@*****.**";
             $subject = "Someone Added to favorites";
             $message = $person->displayName() . " has been added to the favorite list of " . $user->displayName() . "\n";
             $message .= "\nLove Jon";
             $from = "*****@*****.**";
             $headers = "From:" . $from;
             mail($to, $subject, $message, $headers);
             return "{$insert}";
         } else {
             return false;
         }
     }
 }
コード例 #15
0
 public function run($id, $type)
 {
     $controller = $this->getController();
     $itemType = Person::COLLECTION;
     if ($type == "organization") {
         $itemType = Organization::COLLECTION;
     } else {
         if ($type == "event") {
             $itemType = Event::COLLECTION;
         } else {
             if ($type == "project") {
                 $itemType = Project::COLLECTION;
             }
         }
     }
     $item = PHDB::findOne($itemType, array("_id" => new MongoId($id)));
     $viewerMap = array($type => $item);
     $viewerMap[Organization::COLLECTION] = array();
     $viewerMap[Event::COLLECTION] = array();
     $viewerMap[Person::COLLECTION] = array();
     $viewerMap[Project::COLLECTION] = array();
     if (isset($item) && isset($item["links"])) {
         foreach ($item["links"] as $key => $value) {
             foreach ($value as $k => $v) {
                 if (strcmp($key, "memberOf") == 0 || strcmp($key, "organizer") == 0) {
                     $obj = Organization::getById($k);
                     array_push($viewerMap[Organization::COLLECTION], $obj);
                 } else {
                     if (strcmp($key, "knows") == 0 || strcmp($key, "attendees") == 0 || strcmp($key, "contributors") == 0) {
                         $obj = Person::getById($k);
                         array_push($viewerMap[Person::COLLECTION], $obj);
                     } else {
                         if (strcmp($key, "events") == 0) {
                             $obj = Event::getById($k);
                             array_push($viewerMap[Event::COLLECTION], $obj);
                         } else {
                             if (strcmp($key, "projects") == 0) {
                                 $obj = Project::getById($k);
                                 array_push($viewerMap[Project::COLLECTION], $obj);
                             } else {
                                 if (strcmp($key, "members") == 0) {
                                     if (isset($v["type"])) {
                                         if (strcmp($v["type"], Organization::COLLECTION) == 0) {
                                             $obj = Organization::getById($k);
                                             array_push($viewerMap[Organization::COLLECTION], $obj);
                                         } else {
                                             if (strcmp($v["type"], Person::COLLECTION) == 0) {
                                                 $obj = Person::getById($k);
                                                 array_push($viewerMap[Person::COLLECTION], $obj);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $params = array('viewerMap' => $viewerMap);
     $params["typeMap"] = $type;
     $controller->renderPartial("viewer", $params);
 }
コード例 #16
0
ファイル: mainMenu.php プロジェクト: zourite/communecter
<div class="center text-white pull-left menuContainer" >
<?php 
if (isset(Yii::app()->session['userId'])) {
    $me = Person::getById(Yii::app()->session['userId']);
    if (isset($me['profilImageUrl']) && $me['profilImageUrl'] != "") {
        $urlPhotoProfil = Yii::app()->createUrl('/' . $this->module->id . '/document/resized/50x50' . $me['profilImageUrl']);
    } else {
        $urlPhotoProfil = $this->module->assetsUrl . '/images/news/profile_default_l.png';
    }
    ?>

    <a href="#person.detail.id.<?php 
    echo Yii::app()->session['userId'];
    ?>
" onclick="loadByHash( '#person.detail.id.<?php 
    echo Yii::app()->session['userId'];
    ?>
')" class="menuIcon no-floop-item" style="padding: 2px 15px;"><span class="menu-count badge badge-danger animated bounceIn" style="position:absolute;left:8px;"></span>
      <img class="img-circle" id="menu-thumb-profil" width="40" height="40" src="<?php 
    echo $urlPhotoProfil;
    ?>
" alt="image" >
      <span  class="menuline hide homestead" style="padding-top:7px;"> <?php 
    echo Yii::t("common", 'MY DETAIL');
    ?>
</span>
    </a>

    <a  href="#news.index.type.citoyen" 
        onclick="loadByHash( '#news.index.type.citoyens.id.<?php 
    echo Yii::app()->session['userId'];
コード例 #17
0
ファイル: search.php プロジェクト: Jonathan-Law/fhd
         $search_result_file[] = $temp;
     }
 }
 unset($data);
 $data = $database->QuerySingle("SELECT *, MATCH(firstName, middleName, lastName) AGAINST('" . $search_query . "*' IN BOOLEAN MODE) AS score FROM `person` WHERE MATCH(firstName, middleName, lastName) AGAINST('" . $search_query . "*' IN BOOLEAN MODE) ORDER BY score DESC");
 //$results[] = $data;
 if (count($data) == 0) {
     //echo "Search found nothing in Person\n";
 } else {
     foreach ($data as $instance) {
         $temp = recast("Person", arrayToObject($instance));
         $parents = $temp->getParents();
         $temp->parents = array();
         $temp->profilePic = File::getById($temp->profile_pic);
         foreach ($parents as $parent) {
             $tempParent = Person::getById($parent->parentId);
             $tempParent = recast("Person", $tempParent);
             $tempParent->profilePic = File::getById($tempParent->profile_pic);
             $tempParent->dName = $tempParent->displayName();
             $temp->parents[] = $tempParent;
         }
         $temp->dName = $temp->displayName();
         $search_result_people[] = $temp;
     }
 }
 unset($data);
 $data = $database->QuerySingle("SELECT *, MATCH(town, county, state, country, cemetary) AGAINST('" . $search_query . "*' IN BOOLEAN MODE) AS score FROM `place` WHERE MATCH(town, county, state, country, cemetary) AGAINST('" . $search_query . "*' IN BOOLEAN MODE) ORDER BY score DESC");
 //$results[] = $data;
 if (count($data) == 0) {
     //echo "Search found nothing in Place\n";
 } else {
コード例 #18
0
ファイル: Link.php プロジェクト: CivicTechFR/PixelHumain
 private static function checkIdAndType($id, $type)
 {
     if ($type == Organization::COLLECTION) {
         $res = Organization::getById($id);
     } else {
         if ($type == PHType::TYPE_CITOYEN) {
             $res = Person::getById($id);
         } else {
             if ($type == PHType::TYPE_EVENTS) {
                 $res = Event::getById($id);
             } else {
                 if ($type == PHType::TYPE_PROJECTS) {
                     $res = Project::getById($id);
                 } else {
                     throw new CTKException("Can not manage this type of MemberOf : " . $type);
                 }
             }
         }
     }
     if (empty($res)) {
         throw new CTKException("The actor (" . $id . " / " . $type . ") is unknown");
     }
     return $res;
 }
コード例 #19
0
ファイル: functions.php プロジェクト: Jonathan-Law/fhd
function saveTags($tag, $table, $id, $group, $personId, $type, $link)
{
    $database = cbSQLConnect::connect('object');
    if (isset($database)) {
        $fields = array();
        $fields['name'] = $tag;
        $fields['ftable'] = $table;
        $fields['fid'] = $id;
        $fields['category'] = $group;
        $fields['personid'] = $personId > 0 ? $personId : -1;
        $fields['type'] = $type;
        // return data
        // return $fields;
        $insert = $database->SQLInsert($fields, "tags");
        // return true if sucess or false
        if ($insert && $personId > 0) {
            $person = Person::getById($personId);
            $person = recast("Person", $person);
            $message = '
      <html>
      <head>
        <title>Recent upload to a person on your watch list.</title>
      </head>
      <body>
        <p>Something has been uploaded for ' . $person->displayName() . '</p>
        <p>Click <a href="' . $link . '">HERE</a> to view the new document, or go to their page to view new content <a href="/?controller=individual&action=homepage&id=' . $person->id . '">HERE</a></p>
        <br/>
        <p>Thank you for your continued membership!</p>
        <br/>
        <p>Sincerely</p>
        <p>-The Familyhistorydatabase crew</p>
      </body>
      </html>
      ';
            Favorites::sendUpdate($personId, $message);
            return $insert;
        } else {
            return "Insert didn't compute";
        }
    }
}
コード例 #20
0
ファイル: MyAPI.php プロジェクト: Jonathan-Law/fhd
 protected function deactivateIndividual($args)
 {
     $session = mySession::getInstance();
     if (($this->method === 'POST' || $this->method === 'PUT') && $session->isLoggedIn() && $session->isAdmin()) {
         $id = intval(array_shift($args));
         if ($id && is_numeric($id)) {
             $person = Person::getById($id);
             if (isset($person) && $person) {
                 $user = User::current_user();
                 $person->deactivate($user);
                 return $person;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         return 'You may only POST/PUT to this endpoint and Admin is required';
     }
 }
コード例 #21
0
 /**
  * Dashboard Organization
  */
 public function run($id)
 {
     $controller = $this->getController();
     if (empty($id)) {
         throw new CTKException(Yii::t("organisation", "The organization id is mandatory to retrieve the organization !"));
     }
     $organization = Organization::getPublicData($id);
     $events = Organization::listEventsPublicAgenda($id);
     $members = array("citoyens" => array(), "organizations" => array());
     $controller->title = isset($organization["name"]) ? $organization["name"] : "";
     $controller->subTitle = isset($organization["shortDescripion"]) ? $organization["shortDescripion"] : "";
     $controller->pageTitle = "Organization " . $controller->title . " - " . $controller->subTitle;
     if (isset($organization["_id"]) && isset(Yii::app()->session["userId"]) && Link::isLinked((string) $organization["_id"], Organization::COLLECTION, Yii::app()->session["userId"])) {
         $controller->toolbarMBZ = array("<li id='linkBtns'><a href='javascript:;' class='removeMemberBtn text-red tooltips' data-name='" . $organization["name"] . "' data-memberof-id='" . $organization["_id"] . "' data-member-type='" . Person::COLLECTION . "' data-member-id='" . Yii::app()->session["userId"] . "' data-placement='top' data-original-title='Remove from my Organizations' ><i class='disconnectBtnIcon fa fa-unlink'></i>NOT MEMBER</a></li>");
     } else {
         $controller->toolbarMBZ = array("<li id='linkBtns'><a href='javascript:;' class='connectBtn tooltips ' id='addMeAsMemberInfo' data-placement='top' data-original-title='I'm member of this organization' ><i class=' connectBtnIcon fa fa-link '></i>I'M MEMBER</a></li>");
     }
     $contentKeyBase = Yii::app()->controller->id . "." . Yii::app()->controller->action->id;
     $limit = array(Document::IMG_PROFIL => 1, Document::IMG_MEDIA => 5);
     $images = Document::getListDocumentsURLByContentKey($id, $contentKeyBase, Document::DOC_TYPE_IMAGE, $limit);
     $params = array("organization" => $organization);
     $params["contentKeyBase"] = $contentKeyBase;
     $params["images"] = $images;
     $params["events"] = $events;
     $contextMap = array();
     $contextMap["organization"] = $organization;
     $contextMap["events"] = array();
     $contextMap["organizations"] = array();
     $contextMap["people"] = array();
     $organizations = Organization::getMembersByOrganizationId($id, Organization::COLLECTION);
     $people = Organization::getMembersByOrganizationId($id, Person::COLLECTION);
     foreach ($organizations as $key => $value) {
         $newOrga = Organization::getById($key);
         array_push($contextMap["organizations"], $newOrga);
         array_push($members["organizations"], $newOrga);
     }
     foreach ($events as $key => $value) {
         $newEvent = Event::getById($key);
         array_push($contextMap["events"], $newEvent);
     }
     foreach ($people as $key => $value) {
         $newCitoyen = Person::getById($key);
         $profil = Document::getLastImageByKey($key, Person::COLLECTION, Document::IMG_PROFIL);
         if ($profil != "") {
             $newCitoyen["imagePath"] = $profil;
         }
         array_push($contextMap["people"], $newCitoyen);
         array_push($members["citoyens"], $newCitoyen);
     }
     $params["members"] = $members;
     $params["contextMap"] = $contextMap;
     //list
     $params["tags"] = Tags::getActiveTags();
     $lists = Lists::get(array("public", "typeIntervention", "organisationTypes"));
     $params["public"] = $lists["public"];
     $params["organizationTypes"] = $lists["organisationTypes"];
     $params["typeIntervention"] = $lists["typeIntervention"];
     $params["countries"] = OpenData::getCountriesList();
     //Plaquette de présentation
     $listPlaquette = Document::listDocumentByCategory($id, Organization::COLLECTION, Document::CATEGORY_PLAQUETTE, array('created' => 1));
     $params["plaquette"] = reset($listPlaquette);
     $controller->title = isset($organization["name"]) ? $organization["name"] : "";
     $controller->render("dashboard", $params);
 }
コード例 #22
0
ファイル: FamilyTree.php プロジェクト: ramoncarlos/angkan
 public function save()
 {
     $db = mysqli_connect(DBHOST, DBUSERNAME, DBPASSWORD);
     if (!$db) {
         print "\nUnable to save, cannot connect to the DB\n";
     }
     $rc = mysqli_selectdb(DBNAME);
     for ($i = 1; $i < Person::$theCount; $i++) {
         $person = Person::getById($i);
         $cameFromUnionId = 0;
         if ($person->cameFromUnion) {
             $cameFromUnionId = $person->cameFromUnion->id;
         }
         $sql = "INSERT INTO person (personId,name,realName,gender,dateOfBirth,dateOfDeath,cameFromUnionId,ordinal,suppress) VALUES (";
         $sql .= $person->id . ", '" . $person->name . "', '" . $person->realName . "', '" . $person->gender . "', '" . $person->dateOfBirth . "', '" . $person->dateOfDeath . "', " . $cameFromUnionId . ", " . $person->ordinal . ", " . $person->suppress . " ) ";
         $sql .= " ON DUPLICATE KEY UPDATE name='" . $person->name . "', cameFromUnionId= " . $cameFromUnionId;
         $rc = mysqli_query($sql);
         if (!$rc) {
             print "\n>>> error = " . mysqli_error() . " sql= " . $sql;
         }
         // save attributes
         foreach ($person->attribs as $attrName => $attrValue) {
             if (is_array($attrValue)) {
                 $tmp = join(",", $attrValue);
                 $attrValue = $tmp;
             }
             $sql = "INSERT INTO personattr (personId, attrName, attrValue ) VALUES (";
             $sql .= $person->id . ", '" . $attrName . "', '" . addslashes($attrValue) . "' );";
             $rc = mysqli_query($sql);
             if (!$rc) {
                 print "\n>>> error = " . mysqli_error() . " sql= " . $sql;
             }
         }
     }
     // save marriages
     for ($i = 1; $i < Marriage::$theCount; $i++) {
         $marriage = Marriage::getById($i);
         $sql = "INSERT INTO marriage (marriageId, personId1, personId2, suppress) VALUES ( ";
         $sql .= $marriage->id . ', ' . $marriage->personId1 . ', ' . $marriage->personId2 . ', ' . $marriage->suppress . ') ';
         $sql .= " ON DUPLICATE KEY UPDATE personId1 = " . $marriage->personId1 . ", personId2 = " . $marriage->personId2 . ", suppress=" . $marriage->suppress;
         $rc = mysqli_query($sql);
         if (!$rc) {
             print "\n>>> error = " . mysqli_error() . " sql=" . $sql;
         }
     }
     mysqli_close();
 }
コード例 #23
0
ファイル: individual.php プロジェクト: Jonathan-Law/fhd
function handleIndividualAPI($args, $that)
{
    $session = mySession::getInstance();
    if ($that->method === 'GET') {
        if ($that->verb === '') {
            $id = intval(array_shift($args));
            if ($id && is_numeric($id)) {
                $session = mySession::getInstance();
                if ($id > -1) {
                    $person = Person::getById($id);
                    if ($person) {
                        $person->appendNames();
                        $person->birth = Birth::getById($id);
                        if ($person->birth) {
                            $person->birth->birthPlace = Place::getById($person->birth->place);
                        }
                        $person->death = Death::getById($id);
                        if ($person->death) {
                            $person->death->deathPlace = Place::getById($person->death->place);
                        }
                        $person->burial = Burial::getById($id);
                        if ($person->burial) {
                            $person->burial->burialPlace = Place::getById($person->burial->place);
                        }
                        $person->parents = Parents::getParentsOf($id);
                        $person->children = Parents::getChildrenOf($id);
                        $person->spouse = Spouse::getById($id);
                        $person->profilePicture = File::getById($person->profile_pic);
                        return $person;
                    } else {
                        return false;
                    }
                } else {
                    return false;
                }
            }
        } else {
            if ($that->verb === 'submissions') {
                $user = User::current_user();
                $submissions = Person::getSubmissions($user);
                return $submissions;
            } else {
                if ($that->verb === 'allSubmissions' && $session->isAdmin()) {
                    $submissions = Person::getSubmissions();
                    return $submissions;
                } else {
                    if ($that->verb === 'children') {
                        if (count($args) > 2 || count($args) < 2) {
                            return array();
                        } else {
                            $id = intval(array_shift($args));
                            $spouseid = intval(array_shift($args));
                            if ($id && is_numeric($id) && $spouseid && is_numeric($spouseid)) {
                                $children = Person::getChildrenByParents($id, $spouseid);
                                $result = array();
                                if ($children && is_array($children) && count($children)) {
                                    foreach ($children as $child) {
                                        $person = Person::getById($child->child);
                                        $person->appendNames();
                                        $person->profilePicture = File::getById($person->profile_pic);
                                        $result[] = $person;
                                    }
                                }
                                return $result;
                            } else {
                                return array();
                            }
                        }
                    } else {
                        if ($that->verb === 'families') {
                            if (!empty($args)) {
                                $letter = array_shift($args);
                            } else {
                                $letter = 'a';
                            }
                            $all = array_shift($args);
                            $all = $all === "true" ? true : false;
                            $names = array();
                            $families = Person::getLastNames($letter, $all);
                            if ($families) {
                                foreach ($families as $key) {
                                    $names[] = $key['lastName'];
                                }
                            }
                            return $names;
                        } else {
                            if ($that->verb === 'family') {
                                $id = intval(array_shift($args));
                                if ($id && is_numeric($id)) {
                                    $person = Person::getById($id);
                                    $person->appendNames();
                                    $family = new stdClass();
                                    $family->self = $person;
                                    $family->parents = array();
                                    // $family->siblings = array();
                                    $children = $person->getChildren();
                                    $family->children = array();
                                    foreach ($children as $child) {
                                        $temp = Person::getById($child->child);
                                        $temp->appendNames();
                                        $family->children[] = $temp;
                                    }
                                    $spouses = $person->getSpouse();
                                    $family->spouses = array();
                                    foreach ($spouses as $spouse) {
                                        $temp = Person::getById($spouse->spouse);
                                        $temp->appendNames();
                                        $family->spouses[] = $temp;
                                    }
                                    $siblings = array();
                                    $tempsiblings = array();
                                    $person->getParentsGen(4);
                                    $family->parents = $person->parents;
                                    // foreach ($parents as $key) {
                                    //   $parent = Person::getById($key->parentId);
                                    //   $parent->appendNames();
                                    //   $family->parents[] = $parent;
                                    //   // $siblings[] = $parent->getChildren();
                                    // }
                                    // foreach ($siblings as $sibling) {
                                    //   foreach ($sibling as $key) {
                                    //     $test = true;
                                    //     foreach ($tempsiblings as $value) {
                                    //       if ($key->child === $value->child) {
                                    //         $test = false;
                                    //       }
                                    //     }
                                    //     if ($test) {
                                    //       $tempsiblings[] = $key;
                                    //     }
                                    //   }
                                    // }
                                    // foreach ($tempsiblings as $sibling) {
                                    //   if ($sibling->child !== $person->id) {
                                    //     $family->siblings[] = Person::getById($sibling->child);
                                    //   }
                                    // }
                                    // foreach ($family->parents as $parent) {
                                    //   $grandparents = $parent->getParents();
                                    //   foreach ($grandparents as $grandparent) {
                                    //     $temp = Person::getById($grandparent->parentId);
                                    //     $temp->child = $parent->id;
                                    //     $temp->appendNames();
                                    //     $family->grandParents[] = $temp;
                                    //   }
                                    // }
                                    // foreach ($family->grandParents as $parent) {
                                    //   $grandparents = $parent->getParents();
                                    //   foreach ($grandparents as $grandparent) {
                                    //     $temp = Person::getById($grandparent->parentId);
                                    //     $temp->child = $parent->id;
                                    //     $temp->appendNames();
                                    //     $family->greatGrandParents[] = $temp;
                                    //   }
                                    // }
                                    // foreach ($family->greatGrandParents as $parent) {
                                    //   $grandparents = $parent->getParents();
                                    //   foreach ($grandparents as $grandparent) {
                                    //     $temp = Person::getById($grandparent->parentId);
                                    //     $temp->child = $parent->id;
                                    //     $temp->appendNames();
                                    //     $family->greatGreatGrandParents[] = $temp;
                                    //   }
                                    // }
                                    return $family;
                                } else {
                                    return new stdClass();
                                }
                            } else {
                                if ($that->verb === 'familyNames') {
                                    if (!empty($args)) {
                                        $lastName = array_shift($args);
                                    } else {
                                        $lastName = 'Law';
                                    }
                                    $all = array_shift($args);
                                    $all = $all === "true" ? true : false;
                                    $names = array();
                                    $user = User::current_user();
                                    $familyNames = Person::getFirstNames($lastName, $all, $user);
                                    if ($familyNames) {
                                        foreach ($familyNames as $key) {
                                            $key = recast('Person', arrayToObject($key));
                                            $key->appendNames();
                                            $names[] = $key;
                                        }
                                    }
                                    return $names;
                                } else {
                                    if ($that->verb === 'pictures') {
                                        $id = intval(array_shift($args));
                                        if ($id && is_numeric($id)) {
                                            $session = mySession::getInstance();
                                            if ($id > -1) {
                                                $person = Person::getById($id);
                                                if ($person) {
                                                    return File::getByInd($person->id, 'image');
                                                }
                                            }
                                        } else {
                                            return false;
                                        }
                                    } else {
                                        if ($that->verb === 'documents') {
                                            $id = intval(array_shift($args));
                                            if ($id && is_numeric($id)) {
                                                $session = mySession::getInstance();
                                                if ($id > -1) {
                                                    $person = Person::getById($id);
                                                    if ($person) {
                                                        return File::getByInd($person->id, 'document');
                                                    }
                                                }
                                            } else {
                                                return false;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // } else {
        // return false;
        // }
    } else {
        if ($that->method === 'DELETE' && $session->isLoggedIn() && $session->isAdmin()) {
            // } else if ($that->method === 'DELETE'){
            $id = intval($args[0]);
            if (is_numeric($id)) {
                $person = Person::getById($id);
                if ($person) {
                    $birth = Birth::getById($id);
                    if ($birth) {
                        $birth = recast('Birth', $birth);
                        $birth->delete();
                        //delete
                    }
                    $death = Death::getById($id);
                    if ($death) {
                        $death = recast('Death', $death);
                        $death->delete();
                        //delete
                    }
                    $burial = Burial::getById($id);
                    if ($burial) {
                        $burial = recast('Burial', $burial);
                        $burial->delete();
                        //delete
                    }
                    $parents = Parents::getParentsOf($id);
                    if ($parents) {
                        foreach ($parents as $parent) {
                            $parent = recast('Parents', $parent);
                            $parent->delete();
                            //delete $parent
                        }
                    }
                    $children = Parents::getChildrenOf($id);
                    if ($children) {
                        foreach ($children as $child) {
                            $child = recast('Parents', $child);
                            $child->delete();
                            //delete $child
                        }
                    }
                    $mySpouse = Spouse::getById($id);
                    if ($mySpouse) {
                        foreach ($mySpouse as $spouse) {
                            $spouse = recast('Spouse', $spouse);
                            $theirSpouse = Spouse::getById($spouse->personId);
                            if ($theirSpouse) {
                                foreach ($theirSpouse as $otherSpouse) {
                                    $otherSpouse = recast('Spouse', $otherSpouse);
                                    $otherSpouse->delete();
                                    //delete $otherSpouse
                                }
                            }
                            $spouse->delete();
                            //delete $spouse
                        }
                    }
                    $tags = Tag::getByIndId($id);
                    if ($tags) {
                        foreach ($tags as $tag) {
                            $tag = recast('Tag', $tag);
                            $tag->delete();
                        }
                    }
                    $person->delete();
                    return true;
                } else {
                    return true;
                }
            }
            return false;
        } else {
            if (($that->method === 'POST' || $that->method === 'PUT') && $session->isLoggedIn()) {
                $user = User::current_user();
                if (!$user->id) {
                    return false;
                }
                $result = $that->file;
                if (empty($result) || empty($result->person) || empty($result->birth) || empty($result->death)) {
                    return 'we failed on check1';
                    return false;
                }
                // return $result;
                $person = recast('Person', $result->person);
                if ($person->id) {
                    $tempPerson = Person::getById($person->id);
                    $person->submitter = $tempPerson->submitter;
                    $person->status = $tempPerson->status;
                    if ($person->submitter !== $user->id && !($user->rights === 'super' || $user->rights === 'admin')) {
                        return 'we failed on check2';
                        return false;
                    }
                }
                if (!empty($person)) {
                    $personId = $person->save($user);
                } else {
                    return false;
                }
                if (!!$personId) {
                    $person->id = $personId;
                    $birth = recast('Birth', $result->birth);
                    $birth->personId = $personId;
                    $birthId = $birth->save();
                    $birth->id = $birthId;
                    $death = recast('Death', $result->death);
                    $death->personId = $personId;
                    $deathId = $death->save();
                    $death->id = $deathId;
                    if ($result->burial) {
                        $burial = recast('Burial', $result->burial);
                        $burial->personId = $personId;
                        $burialId = $burial->save();
                        $burial->id = $burialId;
                    } else {
                        $burial = false;
                    }
                    if (empty($personId) || empty($birthId) || empty($deathId)) {
                        return 'test';
                        return false;
                    }
                    if ($result->birthPlace) {
                        $birthPlace = recast('Place', $result->birthPlace);
                        $birthPlace->ft_name = "birth";
                        $birthPlace->fkey = $birthId;
                        $birth->place = $birthPlace->save();
                        $birth->save();
                    } else {
                        $birth->place = null;
                        $birth->save();
                    }
                    if ($result->deathPlace) {
                        $deathPlace = recast('Place', $result->deathPlace);
                        $deathPlace->ft_name = "death";
                        $deathPlace->fkey = $deathId;
                        $death->place = $deathPlace->save();
                        $death->save();
                    } else {
                        $death->place = null;
                        $death->save();
                    }
                    if ($burial) {
                        if ($result->burialPlace) {
                            $burialPlace = recast('Place', $result->burialPlace);
                            $burialPlace->ft_name = "burial";
                            $burialPlace->fkey = $burial->id;
                            $burial->place = $burialPlace->save();
                            $burial->save();
                        } else {
                            $burial->place = null;
                            $burial->save();
                        }
                    } else {
                        $burial = Burial::getById($person->id);
                        if ($burial && $burial->id) {
                            $burial = recast('Burial', $burial);
                            $burial->delete();
                        }
                    }
                    if ($result->parents) {
                        if ($person->id) {
                            $parents = Parents::getParentsOf($person->id);
                            if ($parents) {
                                $missing = array();
                                foreach ($parents as $parent) {
                                    if (!objectListContains($result->parents, 'id', $parent->parentId)) {
                                        $missing[] = $parent;
                                    }
                                }
                                foreach ($missing as $parent) {
                                    $parent = recast('Parents', $parent);
                                    $parent->delete();
                                }
                                foreach ($result->parents as $key) {
                                    if (!objectListContains($parents, 'parentId', $key->id)) {
                                        $newPadre = new Parents();
                                        $newPadre->child = $person->id;
                                        $newPadre->gender = $key->sex === 'male' ? 'father' : 'mother';
                                        $newPadre->parentId = $key->id;
                                        $newPadre->save();
                                    }
                                }
                            } else {
                                foreach ($result->parents as $key) {
                                    $newPadre = new Parents();
                                    $newPadre->child = $person->id;
                                    $newPadre->gender = $key->sex === 'male' ? 'father' : 'mother';
                                    $newPadre->parentId = $key->id;
                                    $newPadre->save();
                                }
                            }
                        } else {
                            return 'We have an error';
                        }
                    } else {
                        $parents = Parents::getParentsOf($person->id);
                        if ($parents) {
                            foreach ($parents as $parent) {
                                $parent = recast('Parents', $parent);
                                $parent->delete();
                            }
                        }
                    }
                    if ($result->spouse) {
                        $spouses = Spouse::getAllSpousesById($person->id);
                        if ($spouses) {
                            $missing = array();
                            foreach ($spouses as $spouse) {
                                if (!objectListContains($result->spouse, 'id', $spouse->spouse)) {
                                    $missing[] = $spouse;
                                }
                            }
                            foreach ($missing as $spouse) {
                                $spouse = recast('Spouse', $spouse);
                                $place = Place::getById($spouse->place);
                                if ($place) {
                                    $place = recast('Place', $place);
                                    $place->delete();
                                }
                                $otherSpouse = Spouse::getByPair($spouse->personId, $spouse->spouse);
                                if ($otherSpouse) {
                                    $place = Place::getById($otherSpouse->place);
                                    if ($place) {
                                        $place = recast('Place', $place);
                                        $place->delete();
                                    }
                                    $otherSpouse = recast('Spouse', $otherSpouse);
                                    $otherSpouse->delete();
                                }
                                $spouse->delete();
                            }
                            foreach ($result->spouse as $spouse) {
                                if (!objectListContains($spouses, 'spouse', $spouse->id)) {
                                    Spouse::addSpouse($spouse, $person->id, $spouse->id);
                                    Spouse::addSpouse($spouse, $spouse->id, $person->id);
                                } else {
                                    Spouse::updateSpouse($spouse, $spouse->id, $person->id);
                                    Spouse::updateSpouse($spouse, $person->id, $spouse->id);
                                }
                            }
                        } else {
                            foreach ($result->spouse as $spouse) {
                                Spouse::addSpouse($spouse, $person->id, $spouse->id);
                                Spouse::addSpouse($spouse, $spouse->id, $person->id);
                            }
                        }
                    } else {
                        $spouses = Spouse::getAllSpousesById($person->id);
                        if ($spouses) {
                            foreach ($spouses as $spouse) {
                                $spouse = recast('Spouse', $spouse);
                                $place = Place::getById($spouse->place);
                                if ($place) {
                                    $place = recast('Place', $place);
                                    $place->delete();
                                }
                                $otherSpouse = Spouse::getByPair($spouse->personId, $spouse->spouse);
                                if ($otherSpouse) {
                                    $place = Place::getById($otherSpouse->place);
                                    if ($place) {
                                        $place = recast('Place', $place);
                                        $place->delete();
                                    }
                                    $otherSpouse = recast('Spouse', $otherSpouse);
                                    $otherSpouse->delete();
                                }
                                $spouse->delete();
                            }
                        }
                    }
                    return $person;
                }
                return false;
            } else {
                return "Only accepts POST and GET requests";
            }
        }
    }
}
コード例 #24
0
 function render_tr(&$obj, $style = "")
 {
     global $PH;
     $str_date = '';
     $str_name = '';
     $str_url = '';
     if ($i = DbProjectItem::getById($obj->id)) {
         if ($i->modified) {
             $mod_date = $i->modified;
             $str_date = renderDateHtml($mod_date);
             if ($i->modified_by) {
                 #if($person = Person::getVisibleById($i->modified_by)){
                 if ($person = Person::getById($i->modified_by)) {
                     $str_name = asHtml($person->name);
                     $str_url = $person->getLink();
                 }
             }
             print '<td><span class=date>' . $str_date . '</span><br><span class="sub who">' . __('by') . ' ' . $str_url . '</span></td>';
         } else {
             print "<td class='nowrap'>&nbsp;</td>";
         }
     } else {
         $PH->abortWarning("Could not get modification date of the element.", ERROR_BUG);
         print "<td class='nowrap'>-</td>";
     }
 }
コード例 #25
0
 /**
  * Dashboard Organization
  */
 public function run($id)
 {
     $controller = $this->getController();
     if (empty($id)) {
         throw new CTKException(Yii::t("organisation", "The organization id is mandatory to retrieve the organization !"));
     }
     $organization = Organization::getPublicData($id);
     $events = Organization::listEventsPublicAgenda($id);
     $controller->title = isset($organization["name"]) ? $organization["name"] : "";
     $controller->subTitle = isset($organization["shortDescripion"]) ? $organization["shortDescripion"] : "";
     $controller->pageTitle = $controller->title . " - " . $controller->subTitle;
     $params = array("organization" => $organization);
     $params["events"] = $events;
     //Same content Key base as the dashboard
     $contentKeyBase = Yii::app()->controller->id . ".dashboard";
     $params["contentKeyBase"] = $contentKeyBase;
     $limit = array(Document::IMG_PROFIL => 1, Document::IMG_MEDIA => 5);
     $images = Document::getListDocumentsURLByContentKey($id, $contentKeyBase, Document::DOC_TYPE_IMAGE, $limit);
     $params["images"] = $images;
     $documents = Document::getWhere(array("type" => Organization::COLLECTION, "id" => $id));
     $params["documents"] = $documents;
     $contextMap = array();
     $contextMap["organization"] = $organization;
     $contextMap["events"] = array();
     $contextMap["organizations"] = array();
     $contextMap["people"] = array();
     $organizations = Organization::getMembersByOrganizationId($id, Organization::COLLECTION);
     $people = Organization::getMembersByOrganizationId($id, Person::COLLECTION);
     foreach ($organizations as $key => $value) {
         $newOrga = Organization::getById($key);
         array_push($contextMap["organizations"], $newOrga);
     }
     if (isset($organization["links"]) && isset($organization["links"]["members"])) {
         $equipe = array();
         $ca = array();
         $bureau = array();
         foreach ($organization["links"]["members"] as $key => $value) {
             if ($value["type"] == PHType::TYPE_CITOYEN && isset($value["roles"])) {
                 $person = Person::getById($key);
                 if (!empty($person)) {
                     if (in_array("Bureau", $value["roles"])) {
                         $bureau[$key] = $person;
                     }
                     if (in_array("Conseil d'administration", $value["roles"])) {
                         $ca[$key] = $person;
                     }
                     if (in_array("Equipe", $value["roles"])) {
                         $equipe[$key] = $person;
                     }
                 }
             }
         }
         if (count($equipe) > 0) {
             $params["equipe"] = $equipe;
         }
         if (count($ca) > 0) {
             $params["ca"] = $ca;
         }
         if (count($bureau) > 0) {
             $params["bureau"] = $bureau;
         }
     }
     foreach ($events as $key => $value) {
         $newEvent = Event::getById($key);
         array_push($contextMap["events"], $newEvent);
     }
     foreach ($people as $key => $value) {
         $newCitoyen = Person::getById($key);
         array_push($contextMap["people"], $newCitoyen);
     }
     $params["contextMap"] = $contextMap;
     $params["countries"] = OpenData::getCountriesList();
     $lists = Lists::get(array("organisationTypes"));
     $params["organizationTypes"] = $lists["organisationTypes"];
     $controller->title = isset($organization["name"]) ? $organization["name"] : "";
     $controller->render("dashboard1", $params);
 }
コード例 #26
0
 /**
  * get people (team)
  */
 function getPeople($visible_only = true)
 {
     $ppeople = $this->getProjectPeople(NULL, true, $visible_only);
     $people = array();
     foreach ($ppeople as $pp) {
         if ($p = Person::getById($pp->person)) {
             $people[] = $p;
         }
     }
     return $people;
 }
コード例 #27
0
ファイル: person.php プロジェクト: Jonathan-Law/fhd
 protected function update($user)
 {
     if ($user === null) {
         $user = User::current_user();
     }
     $database = cbSQLConnect::connect('object');
     if (isset($database)) {
         $fields = self::$db_fields;
         // $this->submitter = (int)$user->id;
         if (isset($user) && !isset($user->rights) || !($user->rights === 'super' || $user->rights === 'admin')) {
             $this->status = 'I';
             $tempPerson = Person::getById($this->id);
             if ($tempPerson->status === 'A') {
                 $message = "An old Individual has been updated and will require aproval to the changes:<br><br>";
                 $message .= "<a href='http://dev.familyhistorydatabase.org/#/individual?individual=" . $this->id . "&tab=default'>" . $this->displayName() . "</a><br><br>";
                 $message .= "by " . $user->username . " " . $user->email;
                 $message .= "<br><br>Changes Include:<br>";
                 $message .= print_r(recursive_array_diff((array) $this, (array) $tempPerson), true);
                 $subject = "Old Individual for approval";
                 sendOwnerUpdate($message, $subject);
             }
         } else {
             if (is_null($user)) {
                 return false;
             }
         }
         foreach ($fields as $key) {
             $flag = $database->SQLUpdate("person", $key, $this->{$key}, "id", $this->id);
             if ($flag == "fail") {
                 break;
             }
         }
         if ($flag == "fail") {
             return 'we failed on check2';
             return false;
         } else {
             return $this->id;
         }
     }
     return 'this happened';
 }
コード例 #28
0
ファイル: tag.php プロジェクト: Jonathan-Law/fhd
 public static function getByFileId($id = NULL)
 {
     if ($id) {
         $database = cbSQLConnect::connect('object');
         if (isset($database)) {
             $query = "SELECT * FROM `tag` WHERE `fileid`=" . $id;
             $result = $database->QuerySingle($query);
             $tags = array();
             $tags['person'] = array();
             $tags['place'] = array();
             $tags['other'] = array();
             foreach ($result as $tag) {
                 if ($tag->enum === 'person') {
                     $tempPerson = Person::getById($tag->foreignid);
                     if ($tempPerson) {
                         $tempPerson->text = $tempPerson->selectName() . " (" . $tempPerson->yearBorn . ")";
                         $tags['person'][] = $tempPerson;
                     }
                 } else {
                     if ($tag->enum === 'place') {
                         $place = Place::getById($tag->foreignid);
                         if ($place) {
                             $place = recast('Place', $place);
                             $place->text = $place->getTypeaheadName();
                             $tags['place'][] = $place;
                         }
                     } else {
                         $tags['other'][] = $tag;
                     }
                 }
             }
             return $tags;
         }
     } else {
         return NULL;
     }
 }
コード例 #29
0
ファイル: mainMap.php プロジェクト: Koulio/pixelhumain
	
	/* XS */
	@media screen and (max-width: 768px) {
		.<?php 
echo $moduleName;
?>
 .mapCanvas{}
		.<?php 
echo $moduleName;
?>
 .btn-group-map{}
	}
</style>
<?php 
$myId = Yii::app()->session['userId'];
$myUser = Person::getById($myId);
?>
<script type="text/javascript">

	var Sig;
		
	/**************************** DONNER UN NOM DIFFERENT A LA MAP POUR CHAQUE CARTE ******************************/
	//le nom de cette variable doit changer dans chaque vue pour éviter les conflits (+ vérifier dans la suite du script)
	var mapBg;
	/**************************************************************************************************************/

	//mémorise l'url des assets (si besoin)
	var assetPath 	= "<?php 
echo $this->module->assetsUrl;
?>
";
コード例 #30
0
ファイル: task_more.inc.php プロジェクト: Bremaweb/streber-1
/**
* Submit changes to notes on a person
*
* @ingroup pages
*/
function taskNoteOnPersonEditSubmit()
{
    global $PH;
    global $auth;
    global $g_user_profile_names;
    ### cancel? ###
    if (get('form_do_cancel')) {
        if (!$PH->showFromPage()) {
            $PH->show('personView', array('person' => getOnePassedId('person_id')));
        }
        exit;
    }
    ### temporary object or from database? ###
    $tsk_id = getOnePassedId('tsk', '', true, 'invalid id');
    if ($tsk_id == 0) {
        $task = new Task(array('id' => 0));
    }
    ## eventually needed later when note is a subcategory of task
    /*else {
          if(!$task= Task::getVisiblebyId($tsk_id)) {
              $PH->abortWarning(__("ERROR: could not get task"), ERROR_NOTE);
              return;
          }
      }*/
    ## other parameter ##
    $person_id = getOnePassedId('person_id');
    $prj_id = get('project');
    $prj_new = get('new_project');
    $prj_name = get('new_project_name');
    $assignement1 = get('task_assignement1');
    $assignement2 = get('task_assignement2');
    $also_assignement = get('task_also_assign');
    ### pub level ###
    if ($pub_level = get('task_pub_level')) {
        if ($task->id) {
            if ($pub_level > $task->getValidUserSetPublicLevels()) {
                $PH->abortWarning('invalid data', ERROR_RIGHTS);
            }
        }
        #else {
        #    #@@@ check for person create rights
        #}
        $task->pub_level = $pub_level;
    }
    ## prio ##
    if ($prio = get('task_prio')) {
        $task->prio = $prio;
    }
    ## status ##
    if (!$task->id) {
        $task->status = STATUS_NEW;
    }
    # retrieve all possible values from post-data (with field->view_in_forms == true)
    # NOTE:
    # - this could be an security-issue.
    # @@@ TODO: as some kind of form-edit-behaviour to field-definition
    foreach ($task->fields as $f) {
        $name = $f->name;
        $f->parseForm($task);
    }
    ### validate ###
    $is_ok = true;
    ## no project ##
    if ($prj_id <= 0) {
        if (!isset($prj_new) || !isset($prj_name)) {
            new FeedbackWarning(__("Note requires project"));
            ## and no assignement ##
            if (!isset($assignement1) && !isset($assignement2) && $also_assignement == -1) {
                new FeedbackWarning(__("Note requires assigned person(s)"));
            }
            $is_ok = false;
        }
    }
    ## if project but no assignement ##
    if (!isset($assignement1) && !isset($assignement2) && $also_assignement == -1) {
        $assignement1 = $auth->cur_user->id;
    }
    if (!$is_ok) {
        $PH->show('taskNoteOnPersonEdit', array('tsk' => $task->id, 'person' => $person_id), $task);
        exit;
    }
    ## new project
    if (isset($prj_new) && isset($prj_name)) {
        $pperson = Person::getById($person_id);
        if ($companies = $pperson->getCompanies()) {
            $company_id = $companies[0]->id;
        } else {
            $company_id = 0;
        }
        $new_project = new Project(array('name' => $prj_name, 'company' => $company_id, 'status' => STATUS_NEW, 'prio' => PRIO_NORMAL, 'pub_level' => PUB_LEVEL_OPEN));
        $new_project->insert();
        $prj_id = $new_project->id;
        ## get project ##
        if (!($project = Project::getById($prj_id))) {
            $PH->abortWarning(__("ERROR: could not get project"), ERROR_NOTE);
        }
    } else {
        ## get project ##
        if (!($project = Project::getById($prj_id))) {
            $PH->abortWarning(__("ERROR: could not get project"), ERROR_NOTE);
        }
    }
    ## set project of task ##
    if (!$task->id) {
        $task->project = $project->id;
    }
    ## assigne people to task##
    $new_task_assignments = array();
    $count = 0;
    if (!$task->id) {
        if (isset($assignement1)) {
            $person = Person::getById($assignement1);
            $new_assignment1 = new TaskPerson(array('person' => $assignement1, 'task' => $task->id, 'comment' => sprintf(__("formerly assigned to %s", "task-assigment comment"), $person->name), 'project' => $project->id));
            $new_task_assignments[$count] = $new_assignment1;
            $count++;
        }
        if (isset($assignement2)) {
            $person = Person::getById($assignement2);
            $new_assignment2 = new TaskPerson(array('person' => $assignement2, 'task' => $task->id, 'comment' => sprintf(__("formerly assigned to %s", "task-assigment comment"), $person->name), 'project' => $project->id));
            $new_task_assignments[$count] = $new_assignment2;
            $count++;
        }
        if ($also_assignement != -1) {
            $person = Person::getById($also_assignement);
            $new_assignment_also = new TaskPerson(array('person' => $also_assignement, 'task' => $task->id, 'comment' => sprintf(__("formerly assigned to %s", "task-assigment comment"), $person->name), 'project' => $project->id));
            $new_task_assignments[$count] = $new_assignment_also;
            $count++;
        }
    }
    ## eventually needed later when note is a subcategory of task
    /*else {
          # ToDo: check if people are assigned
      }*/
    ## assigne person to project ##
    $team = array();
    $new_project_assignments = array();
    $count = 0;
    if (!$task->id) {
        $projperson = $project->getPeople(false);
        foreach ($projperson as $projp) {
            $team[$projp->id] = $projp->name;
        }
        if (isset($assignement1)) {
            if (!isset($team[$assignement1])) {
                $person = Person::getById($assignement1);
                $effort_style = $person->settings & USER_SETTING_EFFORTS_AS_DURATION ? 2 : 1;
                $pp_new1 = new ProjectPerson(array('person' => $person->id, 'project' => $project->id, 'name' => $g_user_profile_names[$person->profile], 'adjust_effort_style' => $effort_style));
                $new_project_assignments[$count] = $pp_new1;
                $count++;
            }
        }
        if (isset($assignement2)) {
            if (!isset($team[$assignement2])) {
                $effort_style = $person->settings & USER_SETTING_EFFORTS_AS_DURATION ? 2 : 1;
                $person = Person::getById($assignement2);
                $pp_new2 = new ProjectPerson(array('person' => $person->id, 'project' => $project->id, 'name' => $g_user_profile_names[$person->profile], 'adjust_effort_style' => $effort_style));
                $new_project_assignments[$count] = $pp_new2;
                $count++;
            }
        }
        if ($also_assignement != -1) {
            if (!isset($team[$also_assignement])) {
                $person = Person::getById($also_assignement);
                $effort_style = $person->settings & USER_SETTING_EFFORTS_AS_DURATION ? 2 : 1;
                $pp_new_also = new ProjectPerson(array('person' => $person->id, 'project' => $project->id, 'name' => $g_user_profile_names[$person->profile], 'adjust_effort_style' => $effort_style));
                $new_project_assignments[$count] = $pp_new_also;
                $count++;
            }
        }
    }
    ## eventually needed later when note is a subcategory of task
    /*else{
          # ToDo: check if people are assigned
      }*/
    ## Insert ##
    if ($task->id == 0) {
        $task->insert();
        ### write task-assigments ###
        foreach ($new_task_assignments as $nta) {
            $nta->task = $task->id;
            $nta->insert();
        }
        ### write project-assigments ###
        foreach ($new_project_assignments as $npa) {
            $npa->insert();
        }
        new FeedbackMessage(sprintf(__("Created task %s with ID %s"), $task->getLink(false), $task->id));
    }
    ## eventually needed later when note is a subcategory of task
    /*
    else{
    }
    */
    ### book effort ###
    $book_effort = get('book_effort');
    if ($book_effort) {
        $as_duration = 0;
        if ($pperson = $project->getProjectPeople()) {
            foreach ($pperson as $pp) {
                if ($pp->project == $project->id && $pp->person == $auth->cur_user->id) {
                    if ($pp->adjust_effort_style == 1) {
                        $as_duration = 0;
                    } else {
                        $as_duration = 1;
                    }
                }
            }
        } else {
            $as_duration = 0;
        }
        if (get('creation_time')) {
            $start_time = get('creation_time');
        } else {
            $start_time = '';
        }
        ### build new object ###
        $newEffort = new Effort(array('id' => 0, 'name' => '', 'project' => $project->id, 'task' => $task->id, 'person' => $auth->cur_user->id, 'as_duration' => $as_duration, 'time_start' => $start_time));
        $PH->show('effortEdit', array('effort' => $newEffort->id), $newEffort);
        exit;
    }
    ### display personList ####
    if (!$PH->showFromPage()) {
        $PH->show('personList', array());
    }
}