Exemplo n.º 1
0
 /**
  * Optional method. If exists, allows this class to decide the title for
  * all blockinstances of this type
  */
 public static function get_instance_title(BlockInstance $bi)
 {
     $configdata = $bi->get('configdata');
     if (!empty($configdata['artefactid'])) {
         safe_require('artefact', 'plans');
         $plan = new ArtefactTypePlan($configdata['artefactid']);
         $title = $plan->get('title');
         return $title;
     }
     return '';
 }
 /**
  * Test that an artefact gets deleted.
  */
 public function testArtefactDelete()
 {
     $todelete = new ArtefactTypePlan();
     $data = array('owner' => $this->testuserid, 'title' => 'Test artefact', 'description' => 'Test artefact description');
     $todelete->set('owner', $data['owner']);
     $todelete->set('title', $data['title']);
     $todelete->set('description', $data['description']);
     $todelete->commit();
     $todeleteid = $todelete->get('id');
     $todelete->delete();
     try {
         $deleted = new ArtefactTypePlan($todeleteid);
         $this->fail("Artefact wasn't deleted properly!");
     } catch (Exception $e) {
     }
 }
Exemplo n.º 3
0
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    mahara
 * @subpackage artefact-plans
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
 *
 */
define('INTERNAL', 1);
define('MENUITEM', 'myportfolio/plans');
define('SECTION_PLUGINTYPE', 'artefact');
define('SECTION_PLUGINNAME', 'plans');
require dirname(dirname(dirname(__FILE__))) . '/init.php';
safe_require('artefact', 'plans');
$id = param_integer('id', 0);
if ($id) {
    $plan = new ArtefactTypePlan($id);
    if (!$USER->can_edit_artefact($plan)) {
        throw new AccessDeniedException(get_string('accessdenied', 'error'));
    }
    define('TITLE', get_string('newtask', 'artefact.plans'));
    $form = ArtefactTypeTask::get_form($id);
} else {
    define('TITLE', get_string('newplan', 'artefact.plans'));
    $form = ArtefactTypePlan::get_form();
}
$smarty =& smarty();
$smarty->assign_by_ref('form', $form);
$smarty->assign_by_ref('PAGEHEADING', hsc(TITLE));
$smarty->display('artefact:plans:new.tpl');
Exemplo n.º 4
0
 /**
  * Creates a plan or task from the given entry
  *
  * @param SimpleXMLElement $entry    The entry to create the plan or task from
  * @param PluginImportLeap $importer The importer
  * @return array A list of artefact IDs created, to be used with the artefact mapping.
  */
 private static function create_plan(SimpleXMLElement $entry, PluginImportLeap $importer)
 {
     // First decide if it's going to be a plan or a task depending
     // on whether it has any ancestral plans.
     if (self::get_ancestor_entryid($entry, $importer)) {
         $artefact = new ArtefactTypeTask();
     } else {
         $artefact = new ArtefactTypePlan();
     }
     $artefact->set('title', (string) $entry->title);
     $artefact->set('description', PluginImportLeap::get_entry_content($entry, $importer));
     $artefact->set('owner', $importer->get('usr'));
     if (isset($entry->author->name) && strlen($entry->author->name)) {
         $artefact->set('authorname', $entry->author->name);
     } else {
         $artefact->set('author', $importer->get('usr'));
     }
     if ($published = strtotime((string) $entry->published)) {
         $artefact->set('ctime', $published);
     }
     if ($updated = strtotime((string) $entry->updated)) {
         $artefact->set('mtime', $updated);
     }
     $artefact->set('tags', PluginImportLeap::get_entry_tags($entry));
     // Set completiondate and completed status if we can find them
     if ($artefact instanceof ArtefactTypeTask) {
         $namespaces = $importer->get_namespaces();
         $ns = $importer->get_leap2a_namespace();
         $dates = PluginImportLeap::get_leap_dates($entry, $namespaces, $ns);
         if (!empty($dates['target']['value'])) {
             $completiondate = strtotime($dates['target']['value']);
         }
         $artefact->set('completiondate', empty($completiondate) ? $artefact->get('mtime') : $completiondate);
         if ($entry->xpath($namespaces[$ns] . ':status[@' . $namespaces[$ns] . ':stage="completed"]')) {
             $artefact->set('completed', 1);
         }
     }
     $artefact->commit();
     return array($artefact->get('id'));
 }
Exemplo n.º 5
0
 public static function submit(Pieform $form, $values)
 {
     global $USER, $SESSION;
     $new = false;
     if (!empty($values['plan'])) {
         $id = (int) $values['plan'];
         $artefact = new ArtefactTypePlan($id);
     } else {
         $artefact = new ArtefactTypePlan();
         $artefact->set('owner', $USER->get('id'));
         $new = true;
     }
     $artefact->set('title', $values['title']);
     $artefact->set('description', $values['description']);
     if (get_config('licensemetadata')) {
         $artefact->set('license', $values['license']);
         $artefact->set('licensor', $values['licensor']);
         $artefact->set('licensorurl', $values['licensorurl']);
     }
     $artefact->set('tags', $values['tags']);
     $artefact->commit();
     $SESSION->add_ok_msg(get_string('plansavedsuccessfully', 'artefact.plans'));
     if ($new) {
         redirect('/artefact/plans/plan.php?id=' . $artefact->get('id'));
     } else {
         redirect('/artefact/plans/index.php');
     }
 }
Exemplo n.º 6
0
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */
define('INTERNAL', 1);
define('MENUITEM', 'content/plans');
define('SECTION_PLUGINTYPE', 'artefact');
define('SECTION_PLUGINNAME', 'plans');
define('SECTION_PAGE', 'index');
require dirname(dirname(dirname(__FILE__))) . '/init.php';
safe_require('artefact', 'plans');
define('TITLE', get_string('Plans', 'artefact.plans'));
if (!PluginArtefactPlans::is_active()) {
    throw new AccessDeniedException(get_string('plugindisableduser', 'mahara', get_string('plans', 'artefact.plans')));
}
// offset and limit for pagination
$offset = param_integer('offset', 0);
$limit = param_integer('limit', 10);
$plans = ArtefactTypePlan::get_plans($offset, $limit);
ArtefactTypePlan::build_plans_list_html($plans);
$js = <<<EOF
addLoadEvent(function () {
    {$plans['pagination_js']}
});
EOF;
$smarty = smarty(array('paginator'));
$smarty->assign_by_ref('plans', $plans);
$smarty->assign('strnoplansaddone', get_string('noplansaddone', 'artefact.plans', '<a href="' . get_config('wwwroot') . 'artefact/plans/new.php">', '</a>'));
$smarty->assign('PAGEHEADING', hsc(get_string("Plans", "artefact.plans")));
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->display('artefact:plans:index.tpl');
Exemplo n.º 7
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    mahara
 * @subpackage artefact-plans
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
 *
 */
define('INTERNAL', true);
define('MENUITEM', 'myportfolio/myplans');
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php';
require_once 'pieforms/pieform.php';
require_once 'pieforms/pieform/elements/calendar.php';
require_once get_config('docroot') . 'artefact/lib.php';
safe_require('artefact', 'plans');
define('TITLE', get_string('editplan', 'artefact.plans'));
$id = param_integer('id');
$artefact = new ArtefactTypePlan($id);
if (!$USER->can_edit_artefact($artefact)) {
    throw new AccessDeniedException(get_string('accessdenied', 'error'));
}
$editform = ArtefactTypePlan::get_form($artefact);
$smarty = smarty();
$smarty->assign('editform', $editform);
$smarty->assign('PAGEHEADING', hsc(get_string("editingplan", "artefact.plans")));
$smarty->display('artefact:plans:edit.tpl');
Exemplo n.º 8
0
define('SECTION_PLUGINNAME', 'calendar');
define('SECTION_PAGE', 'index');
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
require dirname(dirname(dirname(__FILE__))) . '/init.php';
require_once dirname(dirname(dirname(__FILE__))) . '/artefact/calendar/lib.php';
require_once dirname(dirname(dirname(__FILE__))) . '/artefact/plans/lib.php';
//require_once(dirname(dirname(dirname(__FILE__))).'/lib/license.php')  ;
require_once 'pieforms/pieform.php';
require_once 'pieforms/pieform/elements/calendar.php';
require_once get_config('docroot') . 'artefact/lib.php';
define('TITLE', get_string('calendar', 'artefact.calendar'));
// offset and limit for pagination
$offset = param_integer('offset', 0);
$limit = param_integer('limit', 100);
$plans = ArtefactTypePlan::get_plans($offset, $limit);
ArtefactTypeCalendar::build_calendar_html($plans);
//javascript
$javascript = <<<JAVASCRIPT

\tfunction toggle_ajax(linkid, colorid, taskid, status, planid, grayid, tasks_per_day){//calls the toggle function and also saves status to db with ajax

\t\tif (window.XMLHttpRequest)// code for IE7+, Firefox, Chrome, Opera, Safari
\t\t  xmlhttp=new XMLHttpRequest();
\t\t  
\t\telse// code for IE6, IE5
\t\t  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

\t \ttoggle(linkid, colorid, taskid, grayid, tasks_per_day);
\t \tvar new_status;
\t \tif(status == 1)