Exemplo n.º 1
0
 public function actionAdd($id = 0)
 {
     if (!empty($id)) {
         $Insurance = Insurance::model()->findByPk($id);
         if (!Yii::app()->user->checkAccess('admin') && ((Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY || Yii::app()->user->getProfile()->company_id != $Insurance->user->company_id) && (Yii::app()->getUser()->getProfile()->modules->insurance != '1' || $Insurance->user_id != Yii::app()->user->id) || Yii::app()->getUser()->getProfile()->company->active == '0')) {
             throw new CHttpException(403);
         }
         $Address = $Insurance->address;
         $ContentManager = null;
     } else {
         if (Yii::app()->user->getProfile()->content_manager == '0') {
             if (!Yii::app()->user->checkAccess('admin') && (Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY && Yii::app()->getUser()->getProfile()->modules->insurance != '1' || Yii::app()->getUser()->getProfile()->company->active == '0')) {
                 throw new CHttpException(403);
             } elseif (!Yii::app()->getUser()->getProfile()->company->validate) {
                 $this->redirect('/complete');
             }
             $ContentManager = null;
         } else {
             $ContentManager = new ContentManager();
         }
         $Insurance = new Insurance();
         $Address = new Address();
         $Address->setscenario('insurance');
     }
     //if(isset($_POST['save'])) {
     if (!empty($_POST)) {
         if (!empty($Insurance->address)) {
             Address::model()->deleteByPk($Insurance->address->address_id);
         }
         if (Yii::app()->user->getProfile()->content_manager == '1' && $id == 0) {
             $ContentManager->setAttributes($_POST['ContentManager'], false);
             $contentValid = $ContentManager->validate();
         } else {
             $contentValid = true;
         }
         $Insurance->setAttributes($_POST['Insurance'], false);
         $Address->setAttributes($_POST['Address'], false);
         $valid = $Address->validate();
         $valid = $Insurance->validate() && $valid && $contentValid;
         if ($valid) {
             if (Yii::app()->user->getProfile()->content_manager == '1' && $id == 0) {
                 $Insurance->user_id = User::createFakeUser($ContentManager);
                 $Insurance->contact_id = $Insurance->user_id;
             }
             $Address->save();
             $Insurance->address_id = $Address->address_id;
             $Insurance->save();
             $Insurance->autosearch();
             //                $this->redirect('/insurance');
             $this->render('insuranceaddsuccess', ['Insurance' => $Insurance, 'contacts' => User::getContact()]);
             exit;
         }
     }
     $this->render('add', ['Insurance' => $Insurance, 'Address' => $Address, 'contacts' => User::getContact(), 'ContentManager' => $ContentManager]);
 }
Exemplo n.º 2
0
 public function actionAdd($id = 0)
 {
     if (!empty($id)) {
         $Custom = Custom::model()->findByPk($id);
         if (!Yii::app()->user->checkAccess('admin') && ((Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY || Yii::app()->user->getProfile()->company_id != $Custom->user->company_id) && (Yii::app()->getUser()->getProfile()->modules->customs != '1' || $Custom->user_id != Yii::app()->user->id) || Yii::app()->getUser()->getProfile()->company->active == '0')) {
             throw new CHttpException(403);
         }
         $ContentManager = null;
     } else {
         if (Yii::app()->user->getProfile()->content_manager == '0') {
             if (!Yii::app()->user->checkAccess('admin') && (Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY && Yii::app()->getUser()->getProfile()->modules->customs != '1' || Yii::app()->getUser()->getProfile()->company->active == '0')) {
                 throw new CHttpException(403);
             } elseif (!Yii::app()->getUser()->getProfile()->company->validate) {
                 $this->redirect('/complete');
             }
             $ContentManager = null;
         } else {
             $ContentManager = new ContentManager();
         }
         $Custom = new Custom();
     }
     $contacts = User::getContact();
     if (!empty($_POST)) {
         if (!empty($_POST['Custom']['custom_id'])) {
             $Custom = Custom::model()->findByPk($_POST['Custom']['custom_id']);
         } else {
             $Custom = new Custom();
         }
         $Custom->setAttributes($_POST['Custom'], false);
         if (Yii::app()->user->getProfile()->content_manager == '1' && $id == 0) {
             $ContentManager->setAttributes($_POST['ContentManager'], false);
         }
         if (!$Custom->validate()) {
             Yii::import('bootstrap.widgets.TbActiveForm');
             if ($ContentManager) {
                 echo TbActiveForm::validate(array($Custom, $ContentManager));
             } else {
                 echo TbActiveForm::validate(array($Custom));
             }
             Yii::app()->end();
         } else {
             if (Yii::app()->user->getProfile()->content_manager == '1' && $id == 0) {
                 $Custom->user_id = User::createFakeUser($ContentManager);
                 $Custom->contact_id = $Custom->user_id;
             }
             $Custom->save();
             $Custom->setPacking($Custom->custom_id, $_POST['Custom']['packing_id']);
             $Custom->autosearch();
             echo CJSON::encode(array('status' => '500', 'redirect' => '/customsaddsuccess/' . $Custom->custom_id));
             Yii::app()->end();
         }
     }
     $this->render('add', ['Custom' => $Custom, 'contacts' => $contacts, 'ContentManager' => $ContentManager]);
 }
 /**
  * Load your component.
  * 
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function load(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $objTemplate, $objDatabase, $objInit, $act;
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_BACKEND:
             $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'LegacyContentMaster.html');
             $cachedRoot = $this->cx->getTemplate()->getRoot();
             $this->cx->getTemplate()->setRoot($this->getDirectory() . '/View/Template/Backend');
             \Permission::checkAccess(6, 'static');
             $cm = new ContentManager($act, $objTemplate, $objDatabase, $objInit);
             $cm->getPage();
             $this->cx->getTemplate()->setRoot($cachedRoot);
             break;
     }
 }
 /**
  * Load your component.
  *
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function load(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $objTemplate, $objDatabase, $objInit, $act, $subMenuTitle, $_ARRAYLANG;
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_BACKEND:
             // @todo: This should be set by SystemComponentBackendController
             $subMenuTitle = $_ARRAYLANG['TXT_CONTENT_MANAGER'];
             $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'LegacyContentMaster.html');
             $cachedRoot = $this->cx->getTemplate()->getRoot();
             $this->cx->getTemplate()->setRoot($this->getDirectory() . '/View/Template/Backend');
             \Permission::checkAccess(6, 'static');
             $cm = new ContentManager($act, $objTemplate, $objDatabase, $objInit);
             $cm->getPage();
             $this->cx->getTemplate()->setRoot($cachedRoot);
             break;
     }
 }
Exemplo n.º 5
0
 function process()
 {
     if ($this->get_value('relative_to_reason_http_base') == 'true') {
         if (substr($this->get_value('url'), 0, 1) == '/') {
             $new_value = substr($this->get_value('url'), 1);
             $this->set_value('url', $new_value);
         }
     }
     parent::process();
 }
Exemplo n.º 6
0
 protected function __construct($db_table)
 {
     $this->db = (new Db())->setTable($db_table);
     //сохраняем имена всех столбцов таблицы в бд
     $fields = [];
     $columns = $this->db->getAll('SHOW COLUMNS FROM #', null, MYSQLI_ASSOC);
     foreach ($columns as $column) {
         $fields[] = $column['Field'];
     }
     parent::__construct($fields);
 }
Exemplo n.º 7
0
 function run_error_checks()
 {
     parent::run_error_checks();
     $es = new entity_selector();
     $es->add_relation('audience_integration.directory_service_value = "' . reason_sql_string_escape($this->get_value('directory_service_value')) . '"');
     $es->add_relation('entity.id != ' . $this->get_value('id'));
     $es->set_num(1);
     $conflicts = $es->run_one(id_of('audience_type'));
     if (!empty($conflicts)) {
         $this->set_error('directory_service_value', 'The Directory Service Value you entered ("' . $this->get_value('directory_service_value') . '") is already in use. Each audience must have a unique directory service value.');
     }
 }
Exemplo n.º 8
0
 public function build_archive()
 {
     $this->path_to_archive_directory = CONTENT_RESOURCE_LOCAL_PATH . "/{$this->resource_id}/";
     $this->archive_builder = new \eol_schema\ContentArchiveBuilder(array('directory_path' => $this->path_to_archive_directory));
     if ($download_directory = ContentManager::download_temp_file_and_assign_extension(self::DUMP_URL)) {
         if (is_dir($download_directory) && file_exists($download_directory . "/names.dmp")) {
             $this->download_directory = $download_directory;
             $this->get_names();
             $this->get_nodes();
             recursive_rmdir($download_directory);
         }
     }
     $this->archive_builder->finalize(true);
 }
Exemplo n.º 9
0
 protected function __construct($path, $class_name)
 {
     if (!is_readable($path) || !is_writable($path)) {
         throw new SystemException($path . ' не найден или недоступен для чтения или записи');
     }
     require_once $path;
     if (!class_exists($class_name)) {
         throw new SystemException('Класс ' . $class_name . ' не найден в ' . $path);
     }
     $this->path = $path;
     $this->className = $class_name;
     //получаем все константы в классе
     $fields = array_keys((new ReflectionClass($class_name))->getConstants());
     if (!$fields) {
         throw new SystemException('В классе ' . $class_name . ' нет ни одной константы');
     }
     parent::__construct($fields);
 }
Exemplo n.º 10
0
 public function build_archive()
 {
     $this->path_to_archive_directory = CONTENT_RESOURCE_LOCAL_PATH . "/{$this->resource_id}/";
     $this->archive_builder = new \eol_schema\ContentArchiveBuilder(array('directory_path' => $this->path_to_archive_directory));
     if ($download_directory = ContentManager::download_temp_file_and_assign_extension(self::DUMP_URL, "")) {
         echo "\ndownload_directory:[{$download_directory}]\n";
         // $download_directory = '/Library/WebServer/Webroot/eol_php_code/applications/content_server/tmp/9f508e44e8038fb56bbc0c9b34eb3ac7';
         if (is_dir($download_directory) && file_exists($download_directory . "/itis.sql")) {
             $this->download_directory = $download_directory;
             $this->all_statuses = array();
             echo "Getting file names...\n";
             $this->get_file_names();
             echo "Getting ranks...\n";
             $this->get_ranks();
             echo "Getting authors...\n";
             $this->get_authors();
             echo "Getting locations...\n";
             $this->get_locations();
             echo "Getting publications...\n";
             $this->get_publications();
             echo "Getting publication links...\n";
             $this->get_publication_links();
             echo "Getting comments...\n";
             $this->get_comments();
             echo "Getting comment links...\n";
             $this->get_comment_links();
             echo "Getting vernaculars...\n";
             $this->get_vernaculars();
             echo "Getting synonyms...\n";
             $this->get_synonyms();
             $this->get_names();
             print_r($this->all_statuses);
             recursive_rmdir($download_directory);
         }
     }
     $this->archive_builder->finalize(true);
 }
Exemplo n.º 11
0
    // setting unique name for visitor to track activity
    $oUser->setFirstName(strtoupper($oUser->getLogin()));
    $oUser->setMiddleName(chr(rand(65, 90)));
    $oUser->setLastName(rand(0, 9999999));
    $oUser->setUserAgent($_SERVER['HTTP_USER_AGENT']);
    $oUser->setCurrentVisitIP($_SERVER['REMOTE_ADDR']);
    $oUser->setCurrentVisitMoment(date('Y-m-d H:i:s'));
    $boolFreshUser = true;
}
// planting an article tree
$ogArticleTree = new NSTree($oDB, $fusebox['tableArticlesTree'], $fusebox['tableArticlesTokens']);
if (!$ogArticleTree->initialize(array('token' => $fusebox['defaultArticleRoot'], 'id_author' => $oUser->getID(), 'moment' => date("Y-m-d H:i:s")))) {
    _throw("FNoArticlesTables", "There is no articles tree table \"{$fusebox['tableArticlesTree']}\" or articles tokens table \"{$fusebox['tableArticlesTokens']}\" present in DB");
}
// adding article manager
$ogArticleManager = new ContentManager($oDB, $ogFuseaction, $oLanguage, $fusebox['tableArticlesTokens'], $fusebox['tableArticles'], $fusebox['tableArticlesComments'], false);
// setting authorship
$ogArticleManager->fAuthorID = $oUser->getID();
$ogArticleManager->fEditorID = $oUser->getID();
// running dry
if (!$ogArticleManager->initialize()) {
    _throw("FNoArticlesTable", "There is no articles table called \"{$fusebox['tableArticles']}\" present in DB");
}
$ogArticleManager->fTitleEditLink = "%s&nbsp;<a href=\"javascript:void(0);\" onClick=\"popupContentForm('" . $myself . "util.showArticleForm', %d, '%s', %d, 1);\">Edit</a>";
$ogArticleManager->fContentEditLink = "%s&nbsp;<a href=\"javascript:void(0);\" onClick=\"popupContentForm('" . $myself . "util.showArticleForm', %d, '%s', %d, 2);\">Edit</a>";
$ogArticleAttachmentManager = new ArticleAttachmentManager($oDB, $ogArticleManager, $fusebox['tableArticleAttachments']);
// creating gallery manager
$ogGalleryManager = new GalleryManager($oDB, $oLanguage, $fusebox['tableGalleriesTokens'], $fusebox['tableGalleries'], $fusebox['tableImagesTokens'], $fusebox['tableImages'], $fusebox['tableGalleriesComments'], $fusebox['tableImagesComments']);
// setting authorship
$ogGalleryManager->fAuthorID = $oUser->getID();
$ogGalleryManager->fEditorID = $oUser->getID();
Exemplo n.º 12
0
 /**
  * @description Testing provider for namespace dummy
  */
 function providertest()
 {
     $this->co = ContentManager::get('dummy:hello-world');
     $this->assertNotNull($this->co);
     $this->assertEquals($this->co->getHtml(), 'hello-world');
 }
Exemplo n.º 13
0
            // get everything into smarty.
            $params['nooutput'] = 1;
            include dirname(__FILE__) . '/action.detail.php';
            $cmsmailer->reset();
            $cmsmailer->SetSubject($subject);
            $cmsmailer->IsHTML(true);
            foreach ($addresses as $one) {
                $cmsmailer->AddAddress($one);
            }
            $body = $this->ProcessTemplateFromDatabase('upload_sendfilerpt');
            $cmsmailer->SetBody($body);
            $cmsmailer->Send();
            // now try to redirect to a different page
            $str = $this->GetPreference('redirect_on_sendfile');
            if ($str != '') {
                $tmp = ContentManager::GetPageIDFromAlias($str);
                if ($tmp) {
                    $this->RedirectContent($tmp);
                    return;
                }
            }
            // redirect isn't set... so display a nice message.
            $message = $this->Lang('msg_file_sent');
        }
    }
}
// give everything to smarty
if (!empty($error)) {
    $smarty->assign('error', $error);
}
if (!empty($message)) {
Exemplo n.º 14
0
?>
		<?php 
require AT_INCLUDE_PATH . 'html/release_date.inc.php';
?>
		<?php 
echo _AT('applies_to_all_sub_pages');
?>
	</div>

	<div class="row">
		<label for="keys"><?php 
echo _AT('keywords');
?>
</label><br />
		<textarea name="keywords" class="formfield" cols="73" rows="2" id="keys"><?php 
echo ContentManager::cleanOutput($_POST['keywords']);
?>
</textarea>
	</div>

	<div class="row">
		<input type="hidden" name="button_1" value="-1" />
		<?php 
if ($contentManager->getNumSections() > 1 - (bool) (!$cid)) {
    echo '<p>', _AT('editor_properties_insturctions_related'), '</p>';
}
?>
<br />
			<table border="0">
			<tr>
				<th><?php 
Exemplo n.º 15
0
$main_theme_folder = get_main_theme_dir(is_customized_theme($_SESSION['prefs']['PREF_THEME']));
$savant->addPath('template', $main_theme_folder . $_SESSION['prefs']['PREF_THEME'] . '/');
require $main_theme_folder . '../themes/' . $_SESSION['prefs']['PREF_THEME'] . '/theme.cfg.php';
// Define the directory where the customized data lives (used by multi sites):
// Main site: [ATutor-root]
// Subsites: [ATutor-root]/sites/[Subsite-URL]/
$theme_path = "";
if (is_customized_theme($_SESSION['prefs']['PREF_THEME'])) {
    $theme_path = AT_SITES_DIR . $_SERVER['HTTP_HOST'] . '/';
}
define('AT_CUSTOMIZED_DATA_DIR', AT_BASE_HREF . $theme_path);
/**************************************************/
/* load in content manager                        */
/**************************************************/
if (isset($_SESSION['course_id'])) {
    $contentManager = new ContentManager($db, isset($_SESSION['course_id']) ? $_SESSION['course_id'] : $_GET['p_course']);
    $contentManager->initContent();
}
/**************************************************/
require AT_INCLUDE_PATH . 'phpCache/phpCache.inc.php';
// cache library
require AT_INCLUDE_PATH . 'lib/utf8.php';
//UTF-8 multibyte library
if (!file_exists(AT_INCLUDE_PATH . '../sha-1factory.js')) {
    require AT_INCLUDE_PATH . 'header.inc.php';
    $msg->printErrors('MISSING_SHA1');
    require AT_INCLUDE_PATH . 'footer.inc.php';
    exit;
}
if (isset($_user_location) && $_user_location == 'users' && $_SESSION['valid_user'] === true && $_SESSION['course_id'] > 0) {
    $_SESSION['course_id'] = 0;
Exemplo n.º 16
0
if (trim($_POST['body_text']) == '<br />') {
    $_POST['body_text'] = '';
}
if ($do_check) {
    $_POST['body_text'] = ContentManager::cleanOutput($_POST['body_text']);
}
?>
<br style="clear:both;"/>
    <div class="row">
        <span id="textSpan">
            <label for="body_text"><strong><?php 
echo _AT('body');
?>
</strong></label><br />
            <textarea name="body_text" id="body_text" cols="80" rows="20"><?php 
echo ContentManager::cleanOutput($_POST['body_text']);
?>
</textarea>
        </span>
        <span id="weblinkSpan">	
            <label for="weblink_text"><?php 
echo _AT('weblink');
?>
</label>
            <input name="weblink_text" id="weblink_text" value="<?php 
echo $_POST['weblink_text'] != '' ? htmlspecialchars($_POST['weblink_text']) : 'http://';
?>
" />
        </span>
    </div>
Exemplo n.º 17
0
 // generate a code, and store it someplace
 // but that means we gotta clean these things up
 // from time to time.
 $code = $this->GenerateRandomPrintableString();
 if (!$this->SetUserTempCode($uid, $code)) {
     $params['error'] = 1;
     $params['message'] = $this->Lang('error_resetalreadysent');
     $params['form'] = 'forgotpw';
     $this->myRedirect($id, 'default', $returnid, $params);
     return;
 }
 // send our funky email
 $page = $this->GetPreference('pageidforgotpasswd');
 $pid = $returnid;
 if ($page) {
     $tpid = ContentManager::GetPageIDFromAlias($page);
     if ($tpid != false) {
         $pid = $tpid;
     }
 }
 $this->smarty->assign('message_forgotpwemail', $this->Lang('message_forgotpwemail'));
 $this->smarty->assign('prompt_code', $this->Lang('message_code'));
 $this->smarty->assign('data_code', $code);
 $this->smarty->assign('prompt_link', $this->Lang('prompt_link'));
 $parms = array('input_uid' => $uid, 'input_code' => $code);
 $config =& $gCms->GetConfig();
 $prettyurl = "feu/verify/{$pid}/{$uid}/{$code}";
 $link = $this->CreateLink($id, 'verifycode', $pid, '', $parms, '', true, false, '', false, $prettyurl);
 $this->smarty->assign('data_link', $this->CreateLink($id, 'verifycode', $pid, $link, $parms));
 $this->smarty->assign('data_url', $link);
 $body = $this->ProcessTemplateFromDatabase('feusers_forgotpasswordemailform');
Exemplo n.º 18
0
	</ul>
</fieldset>
<?php 
}
?>
 -->
	<div class="row">
		<div style="font-weight:bold;"><span class="required" title="<?php 
echo _AT('required_field');
?>
">*</span><label for="ftitle"><?php 
echo _AT('content_folder_title');
?>
</label></div>
		<input type="text" name="title" id="ftitle" size="70" class="formfield" value="<?php 
echo ContentManager::cleanOutput($this->ftitle);
?>
" />
	</div>
	
	<div class="row">
		<div style="font-weight:bold;"><?php 
echo _AT('release_date');
?>
</div>
		<?php 
if ($_POST['day']) {
    ?>
			<?php 
    $today_day = $_POST['day'];
    $today_mon = $_POST['month'];
 function _ExportLoggedInUserVariables($id, &$params, $returnid)
 {
     // replace {$username} with the user name
     $uid = $this->LoggedInId();
     if (!$uid) {
         return;
     }
     $username = $this->LoggedInName();
     // replace {$groupname} with the first groupname we can find that matches
     $smarty = cmsms()->GetSmarty();
     $groups = $this->GetMemberGroupsArray($uid);
     $groupname = $this->GetGroupName($groups[0]['groupid']);
     $smarty->assign('userid', $uid);
     $smarty->assign('username', $username);
     $smarty->assign('link_logout', $this->CreateLink($id, "logout", $returnid, $this->Lang('logout')));
     $prettyurl_logout = 'feu/logout/' . $returnid;
     $logout_feu = $this->CreateLink($id, 'logout', $returnid, '', array(), '', true, false, '', false, $prettyurl_logout);
     $smarty->assign('url_logout', $logout_feu);
     $page = $this->ProcessTemplateFromData($this->GetPreference('pageid_changesettings'));
     if ($page) {
         $pageid = ContentManager::GetPageIDFromAlias($page);
         if ($pageid == false) {
             $smarty->assign('link_changesettings', '<!-- Error could not determine page from alias/id -->');
         } else {
             $smarty->assign('link_changesettings', $this->CreateLink($id, 'default', $pageid, $this->Lang('prompt_changesettings'), array('form' => 'changesettings')));
             //nuno-dev-Pretty Url's
             $prettyurl_changesettings = 'feu/edit/' . $pageid;
             $changesettings_feu = $this->CreateLink($id, 'default', $pageid, '', array('form' => 'changesettings'), '', true, false, '', false, $prettyurl_changesettings);
             $smarty->assign('url_changesettings', $changesettings_feu);
             //end
         }
     } else {
         $smarty->assign('link_changesettings', $this->CreateLink($id, 'default', $returnid, $this->Lang('prompt_changesettings'), array('form' => 'changesettings')));
         //nuno-dev-Pretty Url's
         $prettyurl_changesettings = 'feu/edit/' . $returnid;
         $changesettings_feu = $this->CreateLink($id, 'default', $returnid, '', array('form' => 'changesettings'), '', true, false, '', false, $prettyurl_changesettings);
         $smarty->assign('url_changesettings', $changesettings_feu);
         //end
     }
     $props = $this->GetUserProperties($this->LoggedInId());
     foreach ($props as $p) {
         $smarty->assign($p['title'], $p['data']);
     }
 }
Exemplo n.º 20
0
    echo '0';
}
?>
" />

    <div class="row">
        <span>
            <span class="required" title="<?php 
echo _AT('required_field');
?>
">*</span><label for="ctitle"><strong><?php 
echo _AT('title');
?>
</strong></label>
            <input type="text" name="title" id="ctitle" size="60" class="formfield" value="<?php 
echo ContentManager::cleanOutput($_POST['title']);
?>
" />
        </span>
       <br /> <span class="nowrap">
        <label for="formatting_radios"><span class="required" title="<?php 
echo _AT('required_field');
?>
">*</span><strong><?php 
echo _AT('formatting');
?>
</strong></label>
        <span id="formatting_radios">
            <input type="radio" name="formatting" value="0" id="text" <?php 
if ($_POST['formatting'] == 0) {
    echo 'checked="checked"';
Exemplo n.º 21
0
<?php

$tmpoFuseaction = false;
if (isset($attributes['key'])) {
    if (!($tmpoFuseaction = $oFuseManager->getFuseaction($attributes['key']))) {
        _error("ECannotGetFuseaction", "No fuseaction found");
    }
} elseif (isset($attributes['id'])) {
    if (is_numeric($attributes['id'])) {
        if ($attributes['id'] == 0) {
            $tmpoFuseaction =& $ogFuseaction;
        } elseif (!($tmpoFuseaction = $oFuseManager->getFuseactionByID($attributes['id']))) {
            _error("ECannotGetFuseaction", "No fuseaction found");
        }
    } else {
        _error("EInvalidFuseactionID", "Invalid Fuseaction ID");
    }
} else {
    _error("ENoFuseactionGiven", "No page given");
}
if ($tmpoFuseaction) {
    $tmpoSEOContentManager = new ContentManager($oDB, $tmpoFuseaction, $tmpoLanguage, $fusebox['tableSEOContentTokens'], $fusebox['tableSEOContent'], false);
    $arrTokens = $tmpoSEOContentManager->getTokens();
    $arrLanguages = $oLanguageManager->getLanguages();
    $smarty->assign("tmpoFuseaction", $tmpoFuseaction);
    $smarty->assign("tmpoSEOContentManager", $tmpoSEOContentManager);
    $smarty->assign("arrTokens", $arrTokens);
    $smarty->assign("arrLanguages", $arrLanguages);
}
_display("admin/dspSEOContentTokens.tpl");
Exemplo n.º 22
0
require AT_INCLUDE_PATH . '../mods/_core/imscc/include/ims_template.inc.php';
/* for ims templates + print_organizations() */
require_once AT_INCLUDE_PATH . 'classes/ContentManager.class.php';
/* to retrieve content resources/medias from at_content[text] */
if (isset($_POST['cancel'])) {
    $msg->addFeedback('EXPORT_CANCELLED');
    header('Location: ../index.php');
    exit;
}
$zipfile = new zipfile();
$zipfile->create_dir('resources/');
/* get all the content */
$content = array();
$paths = array();
$top_content_parent_id = 0;
$contentManager = new ContentManager($db, $course_id);
$handler = new ContentOutputParser();
$parser = new XML_HTMLSax();
$parser->set_object($handler);
$parser->set_element_handler('openHandler', 'closeHandler');
if (authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
    $sql = "SELECT *, UNIX_TIMESTAMP(last_modified) AS u_ts FROM %scontent WHERE course_id=%d ORDER BY content_parent_id, ordering";
    $rows_content = queryDB($sql, array(TABLE_PREFIX, $course_id));
} else {
    $sql = "SELECT *, UNIX_TIMESTAMP(last_modified) AS u_ts FROM %scontent WHERE course_id=%d ORDER BY content_parent_id, ordering";
    $rows_content = queryDB($sql, array(TABLE_PREFIX, $course_id));
}
$cid = $_REQUEST['cid'];
//takes care of some system which lost the REQUEST[cid]
foreach ($rows_content as $row) {
    if (authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN) || $contentManager->isReleased($row['content_id']) === TRUE) {
Exemplo n.º 23
0
    ?>
">*</span><label for="body<?php 
    echo $i;
    ?>
"><?php 
    echo _AT('glossary_definition');
    ?>
</label><br />
		<textarea name="definition[<?php 
    echo $i;
    ?>
]" class="formfield" cols="55" rows="7" id="body<?php 
    echo $i;
    ?>
" style="width:90%;"><?php 
    echo ContentManager::cleanOutput($_POST['definition'][$i]);
    ?>
</textarea>
	</div>

	<div class="row">
	<?php 
    echo _AT('glossary_related');
    ?>
<br />
	<?php 
    if ($row_g = mysql_fetch_assoc($this->result_glossary)) {
        echo '<select name="related_term[' . $i . ']">';
        echo '<option value="0"></option>';
        do {
            echo '<option value="' . $row_g['word_id'] . '">' . $row_g['word'] . '</option>';
Exemplo n.º 24
0
 /**
  *  обавить
  * @param int $id
  * @param null $delivery
  * @throws CException
  * @throws CHttpException
  */
 public function actionAdd($id = 0, $delivery = null)
 {
     if (!empty($id)) {
         $Cargo = Cargo::model()->findByPk($id);
         if (!Yii::app()->user->checkAccess('admin') && ((Yii::app()->getUser()->getProfile()->modules->head != \UserModules::DIRECTOR_COMPANY || Yii::app()->user->getProfile()->company_id != $Cargo->user->company_id) && (Yii::app()->getUser()->getProfile()->modules->cargo != '1' || $Cargo->user_id != Yii::app()->user->id) || Yii::app()->getUser()->getProfile()->company->active == '0')) {
             throw new CHttpException(403);
         }
         $AddressesForm = $Cargo->getAddressForm();
         $CostForm = $Cargo->getCostForm();
         $ContentManager = null;
     } else {
         if (Yii::app()->user->getProfile()->content_manager == '0') {
             if (!Yii::app()->user->checkAccess('admin') && (Yii::app()->getUser()->getProfile()->modules->head != \UserModules::DIRECTOR_COMPANY && Yii::app()->getUser()->getProfile()->modules->cargo != '1' || Yii::app()->getUser()->getProfile()->company->active == '0')) {
                 throw new CHttpException(403);
             } elseif (!Yii::app()->getUser()->getProfile()->company->validate) {
                 $this->redirect('/complete');
             }
             $ContentManager = null;
         } else {
             $ContentManager = new ContentManager();
         }
         $Cargo = new Cargo();
         $AddressesForm = new AddressesForm();
         if (isset($delivery)) {
             $product = Product::model()->findByPk($delivery);
             $AddressesForm->from_1_name = $product->getEavAttribute('adres_name');
             $AddressesForm->from_1_address_lat = $product->getEavAttribute('adres_adress_lat');
             $AddressesForm->from_1_address_long = $product->getEavAttribute('adres_adress_long');
             $AddressesForm->from_1_ind = '';
         }
         $CostForm = new CostForm();
     }
     $contacts = User::getContact();
     $Cargo->contact_id = Yii::app()->user->id;
     if (!empty($_POST)) {
         $Cargo->setAttributes($_POST['Cargo'], false);
         $AddressesForm->setAttributes($_POST['AddressesForm'], false);
         if ($Cargo->price_asc == '0') {
             $CostForm->setAttributes($_POST['CostForm'], false);
         }
         if (Yii::app()->user->getProfile()->content_manager == '1' && $id == 0) {
             $ContentManager->setAttributes($_POST['ContentManager'], false);
             $contentValid = $ContentManager->validate();
         } else {
             $contentValid = true;
         }
         $valid = $AddressesForm->validate();
         $valid = $Cargo->validate() && $CostForm->validate() && $valid && $contentValid;
         if (!$valid) {
             Yii::import('bootstrap.widgets.TbActiveForm');
             if ($ContentManager) {
                 echo TbActiveForm::validate(array($Cargo, $AddressesForm, $CostForm, $ContentManager));
             } else {
                 echo TbActiveForm::validate(array($Cargo, $AddressesForm, $CostForm));
             }
             Yii::app()->end();
         } else {
             if (Yii::app()->user->getProfile()->content_manager == '1' && $id == 0) {
                 $Cargo->user_id = User::createFakeUser($ContentManager);
                 $Cargo->contact_id = $Cargo->user_id;
             }
             $Cargo->save();
             $_POST['Cargo']['type_transport'] = '';
             if (isset($Cargo->transport_type_id)) {
                 switch ($Cargo->transport_type_id) {
                     case 20:
                         $_POST['Cargo']['type_transport'] = $_POST['Cargo']['sea_transport'];
                         break;
                     case 21:
                         $_POST['Cargo']['type_transport'] = $_POST['Cargo']['zhd_transport'];
                         break;
                     case 22:
                         $_POST['Cargo']['type_transport'] = $_POST['Cargo']['air_transport'];
                         break;
                     case 72:
                         $_POST['Cargo']['type_transport'] = $_POST['Cargo']['river_transport'];
                         break;
                     default:
                         break;
                 }
             }
             $Cargo->setRelations($_POST['Cargo']);
             $Cargo->setAddress($AddressesForm);
             $Cargo->setCost($CostForm);
             $Cargo->autosearch();
             if ($_POST['Cargo']['customs_clearance'] == 1) {
                 if ($_POST['AddressesForm']['from_1_ind'] == 'RU') {
                     $_POST['AddressesForm']['from_1_ind'] = 'RUS';
                 }
                 if ($_POST['AddressesForm']['to_1_ind'] == 'RU') {
                     $_POST['AddressesForm']['to_1_ind'] = 'RUS';
                 }
                 if ($_POST['AddressesForm']['from_1_ind'] == 'CH') {
                     $_POST['AddressesForm']['from_1_ind'] = 'CHE';
                 }
                 if ($_POST['AddressesForm']['to_1_ind'] == 'CH') {
                     $_POST['AddressesForm']['to_1_ind'] = 'CHE';
                 }
                 $from = DictionaryData::model()->findByAttributes(['code' => $_POST['AddressesForm']['from_1_ind']]);
                 $to = DictionaryData::model()->findByAttributes(['code' => $_POST['AddressesForm']['to_1_ind']]);
                 $Custom = new Custom();
                 $Custom->type_id = $_POST['Cargo']['name_id'];
                 $Custom->packing_id = $_POST['Cargo']['packing_id'];
                 $Custom->country_from = isset($from) ? $from->id : 0;
                 $Custom->country_to = isset($to) ? $to->id : 0;
                 $Custom->weight_netto = $_POST['Cargo']['weight'];
                 $Custom->weight_brutto = $_POST['Cargo']['weight'];
                 $Custom->volume = $_POST['Cargo']['volume'];
                 $Custom->date_from = $_POST['Cargo']['when_from'];
                 $Custom->date_to = $_POST['Cargo']['when_to'];
                 $Custom->user_id = Yii::app()->user->id;
                 $Custom->contact_id = $_POST['Cargo']['contact_id'];
                 $Custom->save();
                 $Custom->autosearch();
             }
             if ($_POST['Cargo']['cargo_insurance'] == 1) {
                 $addrId = Yii::app()->db->createCommand()->select('address_id')->from('site_cargo_address u')->where('cargo_id=:cargo_id', array(':cargo_id' => $Cargo->cargo_id))->order('cargo_id ASC')->limit(1)->queryRow();
                 $addr = Address::model()->findByPk($addrId);
                 $Insurance = new Insurance();
                 $Insurance->category_id = 147;
                 $Insurance->address_id = $addr->address_id;
                 $Insurance->description = '';
                 $Insurance->contact_id = $_POST['Cargo']['contact_id'];
                 $Insurance->create = date('Y-m-d H:i:s');
                 $Insurance->user_id = Yii::app()->user->id;
                 $Insurance->date_to = $_POST['Cargo']['when_to'] != '' ? $_POST['Cargo']['when_to'] : '0000-00-00';
                 $Insurance->save();
                 $Insurance->autosearch();
             }
             echo CJSON::encode(array('status' => '500', 'redirect' => '/cargoaddsuccess/' . $Cargo->cargo_id));
             Yii::app()->end();
         }
     }
     $DictionaryData = \DictionaryData::model()->findAll('group_id=3');
     $this->render('add', ['Cargo' => $Cargo, 'addreses' => $AddressesForm, 'CostForm' => $CostForm, 'contacts' => $contacts, 'ContentManager' => $ContentManager, 'DictionaryData' => $DictionaryData]);
 }
Exemplo n.º 25
0
 public function actionAddcall($id = 0)
 {
     $flZayavka = 1;
     if (!empty($id)) {
         $this->pageTitle = Yii::t('MarketModule.default', 'Редактирование спецтехники');
         $title = Yii::t('MarketModule.default', 'Редактирование заявки на спецтехнику');
     } else {
         $this->pageTitle = Yii::t('MarketModule.default', 'Добавление спецтехники');
         $title = Yii::t('MarketModule.default', 'Добавление заявки на спецтехнику');
     }
     $this->breadcrumbs = array_merge([CHtml::encode(Yii::t('MarketModule.default', 'Заявки на спецтехнику')) => ['/specialtechniquecall']], [CHtml::encode($this->pageTitle)]);
     if (!empty($id)) {
         $SpecialTechnique = SpecialTechnique::model()->findByPk($id);
         if (!Yii::app()->user->checkAccess('admin') && ((Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY || Yii::app()->user->getProfile()->company_id != $SpecialTechnique->user->company_id) && (Yii::app()->getUser()->getProfile()->modules->specialtech != '1' || $SpecialTechnique->user_id != Yii::app()->user->id) || Yii::app()->getUser()->getProfile()->company->active == '0')) {
             throw new CHttpException(403);
         }
         $Address = $SpecialTechnique->address;
         $CostForm = $SpecialTechnique->getCostForm();
         $ContentManager = null;
     } else {
         if (Yii::app()->user->getProfile()->content_manager == '0') {
             if (!Yii::app()->user->checkAccess('admin') && (Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY && Yii::app()->getUser()->getProfile()->modules->specialtech != '1' || Yii::app()->getUser()->getProfile()->company->active == '0')) {
                 throw new CHttpException(403);
             } elseif (!Yii::app()->getUser()->getProfile()->company->validate) {
                 $this->redirect('/complete');
             }
             $ContentManager = null;
         } else {
             $ContentManager = new ContentManager();
         }
         $SpecialTechnique = new SpecialTechnique();
         $Address = new Address();
         $Address->setscenario('specialtechnique');
         $CostForm = new CostForm();
     }
     $contacts = User::getContact();
     if (!empty($_POST)) {
         if (!empty($SpecialTechnique->address)) {
             Address::model()->deleteByPk($SpecialTechnique->address->address_id);
         }
         $SpecialTechnique->setAttributes($_POST['SpecialTechnique'], false);
         $SpecialTechnique->type_request = 'request';
         $CostForm->setAttributes($_POST['CostForm'], false);
         $Address->setAttributes($_POST['Address'], false);
         if (Yii::app()->user->getProfile()->content_manager == '1' && $id == 0) {
             $ContentManager->setAttributes($_POST['ContentManager'], false);
             $contentValid = $ContentManager->validate();
         } else {
             $contentValid = true;
         }
         $valid = $Address->validate();
         $valid = $SpecialTechnique->validate() && $CostForm->validate() && $valid && $contentValid;
         if (!$valid) {
             Yii::import('bootstrap.widgets.TbActiveForm');
             if ($ContentManager) {
                 echo TbActiveForm::validate(array($SpecialTechnique, $Address, $CostForm, $ContentManager));
             } else {
                 echo TbActiveForm::validate(array($SpecialTechnique, $Address, $CostForm));
             }
             Yii::app()->end();
         } else {
             if (Yii::app()->user->getProfile()->content_manager == '1' && $id == 0) {
                 $SpecialTechnique->user_id = User::createFakeUser($ContentManager);
                 $SpecialTechnique->contact_id = $SpecialTechnique->user_id;
             }
             $Address->save();
             $SpecialTechnique->address_id = $Address->address_id;
             $SpecialTechnique->save();
             $SpecialTechnique->setRelations($_POST['SpecialTechnique']);
             $SpecialTechnique->setCost($CostForm);
             $SpecialTechnique->autosearch();
             //$this->redirect('/specialtechniquecall');
             echo CJSON::encode(array('status' => '500', 'redirect' => '/specialaddcallsuccess/' . $SpecialTechnique->special_technique_id));
             Yii::app()->end();
         }
     }
     $this->render('add', ['showPhoto' => false, 'CostForm' => $CostForm, 'SpecialTechnique' => $SpecialTechnique, 'contacts' => $contacts, 'Address' => $Address, 'title' => $title, 'ContentManager' => $ContentManager, 'flZayavka' => $flZayavka]);
 }
Exemplo n.º 26
0
 function match_big_with_small_images()
 {
     $content_manager = new ContentManager();
     $dimension = array(1300, 1080);
     // Jen's choice 1300x1080
     for ($i = 0; $i <= 15; $i++) {
         $source_dir = $this->local_destination . "/BotanicalEuropeana_{$i}";
         $target_dir = "/Volumes/Eli blue/BotanicalEuropeana_small/{$i}/";
         echo "\n {$source_dir}";
         $k = 0;
         foreach (glob("{$source_dir}/*.jpg") as $filename) {
             /* breakdown when caching
                $k++;
                $cont = false;
                if($k >= 0 && $k < 4000)  $cont = true;
                // if($k >= 4000 && $k < 4500)  $cont = true;
                // if($k >= 4500 && $k < 8000)  $cont = true;
                if(!$cont) continue;
                */
             $parts = pathinfo($filename);
             if (!file_exists($target_dir . $parts['filename'] . "_" . implode("_", $dimension) . "." . $parts['extension'])) {
                 echo "\n[{$i}-{$k}] re-sizing... [{$filename}]";
                 $path = str_replace('\\/', '\\/', $filename);
                 $path = str_replace(' ', '\\ ', $path);
                 $destination_path = str_replace('\\/', '\\/', $target_dir);
                 $destination_path = str_replace(' ', '\\ ', $destination_path);
                 $prefix = $parts['filename'];
                 $content_manager->create_smaller_version($path, $dimension, $destination_path . $prefix, implode("_", $dimension));
             } else {
                 echo "\n-done- ";
             }
         }
     }
 }
Exemplo n.º 27
0
function add_update_course($course_data, $isadmin = FALSE)
{
    require_once AT_INCLUDE_PATH . '../mods/_core/file_manager/filemanager.inc.php';
    global $addslashes;
    global $db;
    global $system_courses;
    global $MaxCourseSize;
    global $msg;
    global $_config;
    global $_config_defaults;
    global $stripslashes;
    $Backup = new Backup($db);
    $missing_fields = array();
    if ($course_data['title'] == '') {
        $missing_fields[] = _AT('title');
    }
    if (!$course_data['instructor']) {
        $missing_fields[] = _AT('instructor');
    }
    if ($missing_fields) {
        $missing_fields = implode(', ', $missing_fields);
        $msg->addError(array('EMPTY_FIELDS', $missing_fields));
    }
    $course_data['access'] = $addslashes($course_data['access']);
    $course_data['title'] = $addslashes($course_data['title']);
    $course_data['description'] = $addslashes($course_data['description']);
    $course_data['hide'] = $addslashes($course_data['hide']);
    $course_data['pri_lang'] = $addslashes($course_data['pri_lang']);
    $course_data['created_date'] = $addslashes($course_data['created_date']);
    $course_data['copyright'] = $addslashes($course_data['copyright']);
    $course_data['icon'] = $addslashes($course_data['icon']);
    $course_data['banner'] = $addslashes($course_data['banner']);
    $course_data['course_dir_name'] = $addslashes($course_data['course_dir_name']);
    $course_data['course'] = intval($course_data['course']);
    $course_data['notify'] = intval($course_data['notify']);
    $course_data['hide'] = intval($course_data['hide']);
    $course_data['instructor'] = intval($course_data['instructor']);
    $course_data['category_parent'] = intval($course_data['category_parent']);
    $course_data['rss'] = intval($course_data['rss']);
    // Course directory name (aka course slug)
    if ($course_data['course_dir_name'] != '') {
        //validate the course_dir_name, allow only alphanumeric, underscore.
        if (preg_match('/^[\\w][\\w\\d\\_]+$/', $course_data['course_dir_name']) == 0) {
            $msg->addError('COURSE_DIR_NAME_INVALID');
        }
        //check if the course_dir_name is already being used
        $sql = "SELECT COUNT(course_id) as cnt FROM %scourses WHERE course_id!=%d AND course_dir_name='%s'";
        $num_of_dir = queryDB($sql, array(TABLE_PREFIX, $course_data['course'], $course_data['course_dir_name']), TRUE);
        if (intval($num_of_dir['cnt']) > 0) {
            $msg->addError('COURSE_DIR_NAME_IN_USE');
        }
    }
    // Custom icon
    if ($_FILES['customicon']['name'] != '') {
        // Use custom icon instead if it exists
        $course_data['icon'] = $addslashes($_FILES['customicon']['name']);
    }
    if ($_FILES['customicon']['error'] == UPLOAD_ERR_FORM_SIZE) {
        // Check if filesize is too large for a POST
        $msg->addError(array('FILE_MAX_SIZE', $_config['prof_pic_max_file_size'] . ' ' . _AT('bytes')));
    }
    if ($course_data['release_date']) {
        $day_release = intval($course_data['day_release']);
        $month_release = intval($course_data['month_release']);
        $year_release = intval($course_data['year_release']);
        $hour_release = intval($course_data['hour_release']);
        $min_release = intval($course_data['min_release']);
        if (!checkdate($month_release, $day_release, $year_release)) {
            //or date is in the past
            $msg->addError('RELEASE_DATE_INVALID');
        }
        if (strlen($month_release) == 1) {
            $month_release = "0{$month_release}";
        }
        if (strlen($day_release) == 1) {
            $day_release = "0{$day_release}";
        }
        if (strlen($hour_release) == 1) {
            $hour_release = "0{$hour_release}";
        }
        if (strlen($min_release) == 1) {
            $min_release = "0{$min_release}";
        }
        $release_date = "{$year_release}-{$month_release}-{$day_release} {$hour_release}:{$min_release}:00";
    } else {
        $release_date = "0000-00-00 00:00:00";
    }
    if ($course_data['end_date']) {
        $day_end = intval($course_data['day_end']);
        $month_end = intval($course_data['month_end']);
        $year_end = intval($course_data['year_end']);
        $hour_end = intval($course_data['hour_end']);
        $min_end = intval($course_data['min_end']);
        if (!checkdate($month_end, $day_end, $year_end)) {
            //or date is in the past
            $msg->addError('END_DATE_INVALID');
        }
        if (strlen($month_end) == 1) {
            $month_end = "0{$month_end}";
        }
        if (strlen($day_end) == 1) {
            $day_end = "0{$day_end}";
        }
        if (strlen($hour_end) == 1) {
            $hour_end = "0{$hour_end}";
        }
        if (strlen($min_end) == 1) {
            $min_end = "0{$min_end}";
        }
        $end_date = "{$year_end}-{$month_end}-{$day_end} {$hour_end}:{$min_end}:00";
    } else {
        $end_date = "0000-00-00 00:00:00";
    }
    $initial_content_info = explode('_', $course_data['initial_content'], 2);
    //admin
    $course_quotas = '';
    if ($isadmin) {
        $instructor = $course_data['instructor'];
        $quota = intval($course_data['quota']);
        $quota_entered = intval($course_data['quota_entered']);
        $filesize = intval($course_data['filesize']);
        $filesize_entered = intval($course_data['filesize_entered']);
        //if they checked 'other', set quota=entered value, if it is empty or negative, set to default (-2)
        if ($quota == '2') {
            if ($quota_entered == '' || empty($quota_entered) || $quota_entered < 0) {
                $quota = AT_COURSESIZE_DEFAULT;
            } else {
                $quota = floatval($quota_entered);
                $quota = megabytes_to_bytes($quota);
            }
        }
        //if they checked 'other', set filesize=entered value, if it is empty or negative, set to default
        if ($filesize == '2') {
            if ($filesize_entered == '' || empty($filesize_entered) || $filesize_entered < 0) {
                $filesize = AT_FILESIZE_DEFAULT;
                $msg->addFeedback('COURSE_DEFAULT_FSIZE');
            } else {
                $filesize = floatval($filesize_entered);
                $filesize = megabytes_to_bytes($filesize);
            }
        }
        $course_quotas = "max_quota='{$quota}', max_file_size='{$filesize}',";
    } else {
        $instructor = $_SESSION['member_id'];
        if (!$course_data['course']) {
            $course_quotas = "max_quota=" . AT_COURSESIZE_DEFAULT . ", max_file_size=" . AT_FILESIZE_DEFAULT . ",";
            $row = $Backup->getRow($initial_content_info[0], $initial_content_info[1]);
            if (count($initial_content_info) == 2 && $system_courses[$initial_content_info[1]]['member_id'] == $_SESSION['member_id']) {
                if ($MaxCourseSize < $row['contents']['file_manager']) {
                    $msg->addError('RESTORE_TOO_BIG');
                }
            } else {
                $initial_content_info = intval($course_data['initial_content']);
            }
        } else {
            unset($initial_content_info);
            $course_quotas = "max_quota='{$system_courses[$course_data[course]][max_quota]}', max_file_size='{$system_courses[$course_data[course]][max_file_size]}',";
        }
    }
    if ($msg->containsErrors()) {
        return FALSE;
    }
    //display defaults
    if (!$course_data['course']) {
        $menu_defaults = ",home_links='{$_config['home_defaults']}', main_links='{$_config['main_defaults']}', side_menu='{$_config['side_defaults']}'";
    } else {
        $menu_defaults = ',home_links=\'' . $system_courses[$course_data['course']]['home_links'] . '\', main_links=\'' . $system_courses[$course_data['course']]['main_links'] . '\', side_menu=\'' . $system_courses[$course_data['course']]['side_menu'] . '\'';
    }
    $sql = "REPLACE INTO %scourses \n                SET \n                course_id=%d, \n                member_id='%s', \n                access='%s', \n                title='%s', \n                description='%s', \n                course_dir_name='%s', \n                cat_id=%d, \n                content_packaging='%s', \n                notify=%d, \n                hide=%d, \n                {$course_quotas}\n                primary_language='%s',\n                created_date='%s',\n                rss=%d,\n                copyright='%s',\n                icon='%s',\n                banner='%s',\n                release_date='%s', \n                end_date='%s' \n                {$menu_defaults}";
    $result = queryDB($sql, array(TABLE_PREFIX, $course_data['course'], $course_data['instructor'], $course_data['access'], $course_data['title'], $course_data['description'], $course_data['course_dir_name'], $course_data['category_parent'], $course_data['content_packaging'], $course_data['notify'], $course_data['hide'], $course_data['pri_lang'], $course_data['created_date'], $course_data['rss'], $course_data['copyright'], $course_data['icon'], $course_data['banner'], $release_date, $end_date));
    if (!$result) {
        echo at_db_error();
        echo 'DB Error';
        exit;
    }
    $new_course_id = $_SESSION['course_id'] = at_insert_id();
    if (isset($isadmin)) {
        global $sqlout;
        write_to_log(AT_ADMIN_LOG_REPLACE, 'courses', $result, $sqlout);
    }
    if (isset($isadmin)) {
        //get current instructor and unenroll from course if different from POST instructor
        $old_instructor = $system_courses[$course_data['course']]['member_id'];
        if ($old_instructor != $course_data['instructor']) {
            //remove old from course enrollment
            $sql = "DELETE FROM %scourse_enrollment WHERE course_id=%d AND member_id=%d";
            $result = queryDB($sql, array(TABLE_PREFIX, $course_data['course'], $old_instructor));
            global $sqlout;
            write_to_log(AT_ADMIN_LOG_DELETE, 'course_enrollment', $result, $sqlout);
        }
    }
    //enroll new instructor
    $sql = "REPLACE INTO %scourse_enrollment VALUES (%d, %d, 'y', 0, '" . _AT('instructor') . "', 0)";
    $result = queryDB($sql, array(TABLE_PREFIX, $course_data['instructor'], $new_course_id));
    if (isset($isadmin)) {
        global $sqlout;
        write_to_log(AT_ADMIN_LOG_REPLACE, 'course_enrollment', $result, $sqlout);
    }
    // create the course content directory
    $path = AT_CONTENT_DIR . $new_course_id . '/';
    @mkdir($path, 0700);
    @copy(AT_CONTENT_DIR . 'index.html', AT_CONTENT_DIR . $new_course_id . '/index.html');
    // create the course backup directory
    $path = AT_BACKUP_DIR . $new_course_id . '/';
    @mkdir($path, 0700);
    @copy(AT_CONTENT_DIR . 'index.html', AT_BACKUP_DIR . $new_course_id . '/index.html');
    /* insert some default content: */
    if (!$course_data['course_id'] && $course_data['initial_content'] == '1') {
        $contentManager = new ContentManager($db, $new_course_id);
        $contentManager->initContent();
        $cid = $contentManager->addContent($new_course_id, 0, 1, _AT('welcome_to_atutor'), addslashes(_AT('this_is_content')), '', '', 1, date('Y-m-d H:00:00'));
        $announcement = _AT('default_announcement');
        $sql = "INSERT INTO %snews VALUES (NULL, %d, %d, NOW(), 1, '%s', '%s')";
        $result = queryDB($sql, array(TABLE_PREFIX, $new_course_id, $instructor, _AT('welcome_to_atutor'), $announcement));
        if ($isadmin) {
            global $sqlout;
            write_to_log(AT_ADMIN_LOG_INSERT, 'news', $result, $sqlout);
        }
    } else {
        if (!$course_data['course'] && count($initial_content_info) == 2) {
            $Backup->setCourseID($new_course_id);
            $Backup->restore($material = TRUE, 'append', $initial_content_info[0], $initial_content_info[1]);
        }
    }
    // custom icon, have to be after directory is created
    if ($_FILES['customicon']['tmp_name'] != '') {
        $course_data['comments'] = trim($course_data['comments']);
        $owner_id = $_SESSION['course_id'];
        $owner_type = "1";
        if ($_FILES['customicon']['error'] == UPLOAD_ERR_INI_SIZE) {
            $msg->addError(array('FILE_TOO_BIG', get_human_size(megabytes_to_bytes(substr(ini_get('upload_max_filesize'), 0, -1)))));
        } else {
            if (!isset($_FILES['customicon']['name']) || $_FILES['customicon']['error'] == UPLOAD_ERR_NO_FILE || $_FILES['customicon']['size'] == 0) {
                $msg->addError('FILE_NOT_SELECTED');
            } else {
                if ($_FILES['customicon']['error'] || !is_uploaded_file($_FILES['customicon']['tmp_name'])) {
                    $msg->addError('FILE_NOT_SAVED');
                }
            }
        }
        if (!$msg->containsErrors()) {
            $course_data['description'] = $addslashes(trim($course_data['description']));
            $_FILES['customicon']['name'] = addslashes($_FILES['customicon']['name']);
            if ($course_data['comments']) {
                $num_comments = 1;
            } else {
                $num_comments = 0;
            }
            $path = AT_CONTENT_DIR . $owner_id . "/custom_icons/";
            if (!is_dir($path)) {
                @mkdir($path);
            }
            // if we can upload custom course icon, it means GD is enabled, no need to check extension again.
            $gd_info = gd_info();
            $supported_images = array();
            if ($gd_info['GIF Create Support']) {
                $supported_images[] = 'gif';
            }
            if ($gd_info['JPG Support'] || $gd_info['JPEG Support']) {
                $supported_images[] = 'jpg';
            }
            if ($gd_info['PNG Support']) {
                $supported_images[] = 'png';
            }
            // check if this is a supported file type
            $filename = $stripslashes($_FILES['customicon']['name']);
            $path_parts = pathinfo($filename);
            $extension = strtolower($path_parts['extension']);
            $image_attributes = getimagesize($_FILES['customicon']['tmp_name']);
            if ($extension == 'jpeg') {
                $extension = 'jpg';
            }
            // resize the original but don't backup a copy.
            $width = $image_attributes[0];
            $height = $image_attributes[1];
            $original_img = $_FILES['customicon']['tmp_name'];
            $thumbnail_img = $path . $_FILES['customicon']['name'];
            if ($width > $height && $width > 79) {
                $thumbnail_height = intval(79 * $height / $width);
                $thumbnail_width = 79;
                if (!resize_image($original_img, $thumbnail_img, $height, $width, $thumbnail_height, $thumbnail_width, $extension)) {
                    $msg->addError('FILE_NOT_SAVED');
                }
            } else {
                if ($width <= $height && $height > 79) {
                    $thumbnail_height = 100;
                    $thumbnail_width = intval(100 * $width / $height);
                    if (!resize_image($original_img, $thumbnail_img, $height, $width, $thumbnail_height, $thumbnail_width, $extension)) {
                        $msg->addError('FILE_NOT_SAVED');
                    }
                } else {
                    // no resizing, just copy the image.
                    // it's too small to resize.
                    copy($original_img, $thumbnail_img);
                }
            }
        } else {
            $msg->addError('FILE_NOT_SAVED');
        }
    }
    //----------------------------------------
    /* delete the RSS feeds just in case: */
    if (file_exists(AT_CONTENT_DIR . 'feeds/' . $new_course_id . '/RSS1.0.xml')) {
        @unlink(AT_CONTENT_DIR . 'feeds/' . $course_data['course'] . '/RSS1.0.xml');
    }
    if (file_exists(AT_CONTENT_DIR . 'feeds/' . $new_course_id . '/RSS2.0.xml')) {
        @unlink(AT_CONTENT_DIR . 'feeds/' . $new_course_id . '/RSS2.0.xml');
    }
    if ($isadmin) {
        $_SESSION['course_id'] = -1;
    }
    $_SESSION['course_title'] = $stripslashes($course_data['title']);
    return $new_course_id;
}
<form action="<?php echo $_SERVER['PHP_SELF']; if ($this->cid > 0) echo '?cid='.$this->cid; else if ($this->pid > 0) echo '?pid='.$this->pid;?>" method="post" name="form"> 
<div class="input-form" style="width:95%;margin-left:1.5em;">
<!-- <?php
if ($this->shortcuts): 
?>
 <fieldset id="shortcuts" style="margin-top:1em;float:right;clear:right;"><legend><?php echo _AT('shortcuts'); ?></legend>
	<ul>
		<?php foreach ($this->shortcuts as $link): ?>
			<li><a href="<?php echo $link['url']; ?>"><?php echo $link['title']; ?></a></li>
		<?php endforeach; ?>
	</ul>
</fieldset>
<?php endif; ?> -->
	<div class="row">
		<div style="font-weight:bold;"><span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="ftitle"><?php echo _AT('content_folder_title');  ?></label></div>
		<input type="text" name="title" id="ftitle" size="70" class="formfield" value="<?php echo ContentManager::cleanOutput($this->ftitle); ?>" />
	</div>
	
	<div class="row">
		<div style="font-weight:bold;"><?php echo _AT('release_date');  ?></div>
		<?php if ($_POST['day']) { ?>
			<?php
				$today_day   = $_POST['day'];
				$today_mon   = $_POST['month'];
				$today_year  = $_POST['year'];

				$today_hour  = $_POST['hour'];
				$today_min   = $_POST['min'];		
		}?>
		<?php require(AT_INCLUDE_PATH.'html/release_date.inc.php');	?>
	</div>
Exemplo n.º 29
0
    $sqlarray = $dbdict->DropColumnSQL(cms_db_prefix() . "modules", "active");
    $dbdict->ExecuteSQLArray($sqlarray);
    $sqlarray = $dbdict->AddColumnSQL(cms_db_prefix() . "modules", "active I1");
    $dbdict->ExecuteSQLArray($sqlarray);
    $query = "UPDATE " . cms_db_prefix() . "modules SET active = tmp";
    $db->Execute($query);
    $sqlarray = $dbdict->DropColumnSQL(cms_db_prefix() . "modules", "tmp");
    $dbdict->ExecuteSQLArray($sqlarray);
} else {
    $sqlarray = $dbdict->AddColumnSQL(cms_db_prefix() . "modules", "active I1");
    $dbdict->ExecuteSQLArray($sqlarray);
}
echo "[done]</p>";
echo "<p>Fixing permission names...";
$query = "UPDATE " . cms_db_prefix() . "permissions set permission_name = 'Add Global Content Blocks', permission_text = 'Add Global Content Blocks' WHERE permission_name = 'Add Html Blobs'";
$db->Execute($query);
$query = "UPDATE " . cms_db_prefix() . "permissions set permission_name = 'Modify Global Content Blocks', permission_text = 'Modify Global Content Blocks' WHERE permission_name = 'Modify Html Blobs'";
$db->Execute($query);
$query = "UPDATE " . cms_db_prefix() . "permissions set permission_name = 'Remove Global Content Blocks', permission_text = 'Remove Global Content Blocks' WHERE permission_name = 'Remove Html Blobs'";
$db->Execute($query);
$query = "UPDATE " . cms_db_prefix() . "permissions set permission_name = 'Modify User-defined Tags', permission_text = 'Modify User-defined Tags' WHERE permission_name = 'Modify Code Blocks'";
$db->Execute($query);
echo "[done]</p>";
echo '<p>Updating hierarchy positions...';
ContentManager::SetAllHierarchyPositions();
echo '[done]</p>';
echo '<p>Updating schema version... ';
$query = "UPDATE " . cms_db_prefix() . "version SET version = 18";
$db->Execute($query);
echo '[done]</p>';
# vim:ts=4 sw=4 noet
Exemplo n.º 30
0
">*</span><label for="subject"><?php 
echo _AT('subject');
?>
</label><br />
		<input type="text" name="subject" id="subject" value="<?php 
if ($subject != '' && $_POST['subject'] == '') {
    if ($_GET['reply'] && !($substr($subject, 0, 2) == _AT('re'))) {
        $subject = _AT('re') . ' : ' . $subject;
    } else {
        if ($_GET['forward'] && !($substr($subject, 0, 2) == _AT('fwd'))) {
            $subject = _AT('fwd') . ' : ' . $subject;
        }
    }
    echo ContentManager::cleanOutput($subject);
} else {
    echo ContentManager::cleanOutput($_POST['subject']);
}
?>
" size="40" maxlength="100" />
	</div>

	<div class="row">
		<span class="required" title="<?php 
echo _AT('required_field');
?>
">*</span><label for="body"><?php 
echo _AT('message');
?>
</label><br />
		<textarea name="message" id="body" rows="15" cols="45"><?php 
if ($body != '') {