コード例 #1
0
ファイル: globals.php プロジェクト: IASA-GR/appdb-core
 private static function mailDispatchReport($recipients, $filename, $folder)
 {
     $reportcsv = file_get_contents($folder . $filename . ".csv");
     if ($reportcsv === false) {
         error_log("[SocialReport::mailDispatch]: Could not load report " . $filename);
         return false;
     }
     $subject = "EGI AppDB Social media sharing report (" . date('Y') . "-" . date('m') . "-" . date('d') . ")";
     $sbody = "This is an automatically generated report for social media sharing count per registered software item.";
     $sbody = $sbody . "Please find attached a CSV file containing the report.<br/>";
     $sbody = $sbody . "You can access this report at http://" . $_SERVER['APPLICATION_UI_HOSTNAME'] . "/reports/social/" . $filename . ".csv <br/><br/>";
     $sbody = $sbody . "Regards,<br/>";
     $sbody = $sbody . "EGI AppDB Team";
     $textsbody = simpleHTML2Text($sbody);
     $att = array("data" => $reportcsv, "type" => "application/vnd.ms-excel", "name" => $filename . ".csv");
     //sendMultipartMail($subject, $recipients, $textsbody, $sbody, '*****@*****.**', 'enadyskolopassword', '*****@*****.**',$att, false,array("Precedence"=>"bulk"));
     EmailService::sendBulkReport($subject, $recipients, $textsbody, $sbody, EmailConfiguration::getSupportAddress(), $att);
 }
コード例 #2
0
ファイル: AppsController.php プロジェクト: IASA-GR/appdb-core
 public function tagsAction()
 {
     $this->_helper->layout->disableLayout();
     $uid = $this->session->userid;
     $urole = $this->session->userRole;
     $action = isset($_GET["action"]) ? strtolower($_GET["action"]) : '';
     $appid = isset($_GET["id"]) ? $_GET["id"] : -1;
     $tag = isset($_GET["tag"]) ? trim($_GET["tag"]) : '';
     $tag = urldecode($tag);
     $tag = str_replace(" ", ".", $tag);
     if ($appid === -1) {
         $this->view->Error = "no appid given";
         return;
     }
     if ($tag === '' && $action !== '') {
         $this->view->Error = "no tag given";
         return;
     }
     if ($action === "add" || $action === "remove") {
         if (is_null($uid)) {
             $this->view->Error = "not logged in";
             return;
         }
         $apptags = new Default_Model_AppTags();
         $flt1 = $apptags->filter;
         $flt1->appid->equals($appid)->and($flt1->tag->ilike($tag));
         if (count($apptags->items) > 0) {
             if ($action === "remove") {
                 if ($apptags->items[0]->researcherid !== $uid) {
                     $isOwner = false;
                     $isAdmin = false;
                     $apps = new Default_Model_Applications();
                     $apps->filter->appid->equals($appid);
                     //Check if current user is the owner of the applicaiton entry
                     if (count($apps->items) > 0) {
                         if ($apps->items[0]->addedBy === $uid || $apps->items[0]->ownerid === $uid) {
                             $isOwner = true;
                         }
                     }
                     //Check if current user role is administrator or manager
                     if (userIsAdminOrManager($uid)) {
                         $isAdmin = true;
                     }
                     if (!($isOwner || $isAdmin)) {
                         //check if the current user is the submitter of the tag
                         $apptags = new Default_Model_AppTags();
                         $flt1 = $apptags->filter;
                         $flt1->appid->equals($appid)->and($flt1->tag->ilike($tag))->and($flt1->researcherid->equals($uid));
                         $apptagsitems = $apptags->items;
                         if (count($apptagsitems) == 0) {
                             $this->view->Error = 'permission denied';
                             return;
                         }
                     }
                 }
             }
         }
     } else {
         if ($tag != '') {
             $this->view->Error = "No action given";
             return;
         }
     }
     $p = new Default_Model_Permissions();
     $p->filter->researcherid->equals($this->session->userid)->and($p->filter->actionid->equals(24));
     $pc = $p->count();
     if ($pc === 0) {
         $this->view->Error = "The user is not allowed to change tags";
         return;
     }
     global $application;
     $db = $application->getBootstrap()->getResource('db');
     $db->setFetchMode(Zend_Db::FETCH_OBJ);
     try {
         if ($action === "add") {
             $t = substr($tag, 0, 1);
             if (preg_match("/[A-Za-z]/", $t) <= 0) {
                 $this->view->Error = "Tags must start with a text character.";
                 return;
             }
             if (preg_match("/[\\>\\<\\=\\!]/", $tag) > 0) {
                 $this->view->Error = "Tag contains invalid characters (> < = !)";
                 return;
             }
             if (strlen($tag) > 50) {
                 $this->view->Error = "Tags must be less than 50 characters long.";
                 return;
             }
             $tags = new Default_Model_AppTags();
             $tags->filter->appid->equals($appid)->and($tags->filter->tag->ilike($tag));
             if ($tags->count() == 0) {
                 $t = new Default_Model_AppTag();
                 $t->appid = $appid;
                 $t->tag = $tag;
                 $t->researcherid = $uid;
                 $tags->add($t);
             }
         } else {
             if ($action === "remove") {
                 $tags = new Default_Model_AppTags();
                 $tags->filter->appid->equals($appid)->and($tags->filter->tag->ilike($tag));
                 $tags->refresh();
                 if ($tags->count() > 0) {
                     $tags->remove($tags->items[0]);
                 }
             } else {
                 $apps = new Default_Model_Applications();
                 $apps->filter->id->equals($appid);
                 $c = $apps->count();
                 if ($c > 0) {
                     $apps->refresh();
                     $kws = $apps->items[0]->keywords;
                     $kws = is_array($kws) ? implode(",", $kws) : $kws;
                     $kws = str_replace(array("{", "}", "\""), "", $kws);
                     $this->view->Response = $kws;
                     $this->view->total = $apps->count();
                     return;
                 } else {
                     $this->view->Error = "Could not find the software";
                 }
             }
         }
     } catch (Exception $e) {
         $this->view->Error = simpleHTML2Text($e->getMessage());
         return;
     }
     $this->view->Response = "OK";
 }